From patchwork Tue Jun 19 16:40:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 139224 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp5428487lji; Tue, 19 Jun 2018 09:41:19 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLu4lcnAR8veXQU+YHL1I9tIj50oKs7K9Rxqawo80ePGTRSTefDE6qJAVmkL1nRhi7o5Usk X-Received: by 2002:a9d:2713:: with SMTP id r19-v6mr11648668ota.93.1529426479772; Tue, 19 Jun 2018 09:41:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529426479; cv=none; d=google.com; s=arc-20160816; b=hJWRZm1vf5GxI0wBBLK1alTm8OOeNFKMzTy0htlcPEnA6RnvK4ZtiZSvZXo58KzFy6 rEOUrhaNjvZK/KvlXbF9nRVy1k7xqjNtUxmbGhJ47CjscscFyXe0GY2wzkI5KVoQK6TG +quLegphP8W2DujO22AfgJuYxrODOn38a5ve0Fh0sgsqnSPd9yQq/+hmX6giLlcECOyZ BeEHnvEeFksztEPVUoqnnx28je8rYt9ipLoirD0th5qwh7gIe8FeWGKpt+eHd6AVg5vN HMId1BRwGB2bN0OWlJTgtaB56YTe0cjBs1iYEN9aYVfkEwaGFMhKNuOHykZZGFLw7v93 gu8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:references :in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=pIOvFYEPB2irNwtbo8se6yvirzNoD0K2gqS5s9kK/L0=; b=tX0XzqpW6255wC7TEs+Dru8Z7sbtFxkz21OHXDntwVeSVGIJqULB713UENBc1MKqin ASznpLMzK5OXWHZWnsEMxPJSNqh2t8O3gdSFDNb4VlqggMgLimkevWy9T/Q3jCbT7bp+ Ymr96txXttGFzanXj77YfZxtqr4AnL0TofDJtn875wZKRtp13EpepA+spNQjfGURloU6 6meohN8p8hec9HncHJQS11lgdhnsd72vw8awxcCTpZk1scdN1x7bXBHgYjbchd3BF24Z M6Inqs3yCYCocXV/IyBkdDw96xMTlIVj2rH7UYwkkvuaPFtg6Ouc7ZVOi9aeL4syZjLS TAIA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id r25-v6si44891otd.76.2018.06.19.09.41.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Jun 2018 09:41:19 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2A7DA83F3E; Tue, 19 Jun 2018 16:41:18 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BEDAF5D9C5; Tue, 19 Jun 2018 16:41:17 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 2EC171800538; Tue, 19 Jun 2018 16:41:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5JGfEWs011289 for ; Tue, 19 Jun 2018 12:41:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id 668812018077; Tue, 19 Jun 2018 16:41:14 +0000 (UTC) Delivered-To: libvirt-list@redhat.com Received: from worklaptop.bos.redhat.com (dhcp-17-157.bos.redhat.com [10.18.17.157]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4D55C2026D68; Tue, 19 Jun 2018 16:41:14 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Tue, 19 Jun 2018 12:40:50 -0400 Message-Id: <0d6bfcf551588a39759879580fb8ab0163fbe589.1529426092.git.crobinso@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/6] qemu: command: replace vlan= with netdev= for legacy nic X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 19 Jun 2018 16:41:18 +0000 (UTC) VMs with hardcoded platform network devices are forced to use old style '-net nic' command line config. Current we use qemu's vlan option to hook this with the '-netdev' host side of things. However since qemu 1.2 there is '-net nic,netdev=X' option for explicitly referencing a netdev ID, which is more inline with typical VM commandlines, so let's switch to that Signed-off-by: Cole Robinson --- src/qemu/qemu_command.c | 52 ++++++------------- .../arm-vexpressa9-basic.args | 4 +- 2 files changed, 19 insertions(+), 37 deletions(-) -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 31a0b7761a..a2687c5693 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3354,15 +3354,15 @@ qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem) static char * qemuBuildLegacyNicStr(virDomainNetDefPtr net, - int vlan) + int vlan ATTRIBUTE_UNUSED) { char *str; char macaddr[VIR_MAC_STRING_BUFLEN]; ignore_value(virAsprintf(&str, - "nic,macaddr=%s,vlan=%d%s%s%s%s", + "nic,macaddr=%s,netdev=host%s%s%s%s%s", virMacAddrFormat(&net->mac, macaddr), - vlan, + net->info.alias, (net->model ? ",model=" : ""), (net->model ? net->model : ""), (net->info.alias ? ",name=" : ""), @@ -3374,7 +3374,7 @@ qemuBuildLegacyNicStr(virDomainNetDefPtr net, char * qemuBuildNicDevStr(virDomainDefPtr def, virDomainNetDefPtr net, - int vlan, + int vlan ATTRIBUTE_UNUSED, unsigned int bootindex, size_t vhostfdSize, virQEMUCapsPtr qemuCaps) @@ -3523,10 +3523,7 @@ qemuBuildNicDevStr(virDomainDefPtr def, virBufferAsprintf(&buf, ",host_mtu=%u", net->mtu); } - if (vlan == -1) - virBufferAsprintf(&buf, ",netdev=host%s", net->info.alias); - else - virBufferAsprintf(&buf, ",vlan=%d", vlan); + virBufferAsprintf(&buf, ",netdev=host%s", net->info.alias); virBufferAsprintf(&buf, ",id=%s", net->info.alias); virBufferAsprintf(&buf, ",mac=%s", virMacAddrFormat(&net->mac, macaddr)); @@ -3555,7 +3552,7 @@ qemuBuildNicDevStr(virDomainDefPtr def, char * qemuBuildHostNetStr(virDomainNetDefPtr net, virQEMUDriverPtr driver, - int vlan, + int vlan ATTRIBUTE_UNUSED, char **tapfd, size_t tapfdSize, char **vhostfd, @@ -3670,13 +3667,7 @@ qemuBuildHostNetStr(virDomainNetDefPtr net, break; } - if (vlan >= 0) { - virBufferAsprintf(&buf, "vlan=%d,", vlan); - if (net->info.alias) - virBufferAsprintf(&buf, "name=host%s,", net->info.alias); - } else { - virBufferAsprintf(&buf, "id=host%s,", net->info.alias); - } + virBufferAsprintf(&buf, "id=host%s,", net->info.alias); if (is_tap) { if (vhostfdSize) { @@ -8494,22 +8485,20 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver, goto cleanup; } + if (!(host = qemuBuildHostNetStr(net, driver, + vlan, + tapfdName, tapfdSize, + vhostfdName, vhostfdSize))) + goto cleanup; + virCommandAddArgList(cmd, "-netdev", host, NULL); + /* Possible combinations: * - * 1. Old way: -net nic,model=e1000,vlan=1 -net tap,vlan=1 - * 2. New way: -netdev type=tap,id=netdev1 -device e1000,id=netdev1 - * - * NB: The backend and frontend are reversed above + * Old way: -netdev type=tap,id=netdev1 \ + * -net nic,model=e1000,netdev=netdev1 + * New way: -netdev type=tap,id=netdev1 -device e1000,id=netdev1 */ - if (qemuDomainSupportsNicdev(def, net)) { - if (!(host = qemuBuildHostNetStr(net, driver, - vlan, - tapfdName, tapfdSize, - vhostfdName, vhostfdSize))) - goto cleanup; - virCommandAddArgList(cmd, "-netdev", host, NULL); - if (!(nic = qemuBuildNicDevStr(def, net, vlan, bootindex, vhostfdSize, qemuCaps))) goto cleanup; @@ -8518,13 +8507,6 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver, if (!(nic = qemuBuildLegacyNicStr(net, vlan))) goto cleanup; virCommandAddArgList(cmd, "-net", nic, NULL); - - if (!(host = qemuBuildHostNetStr(net, driver, - vlan, - tapfdName, tapfdSize, - vhostfdName, vhostfdSize))) - goto cleanup; - virCommandAddArgList(cmd, "-net", host, NULL); } ret = 0; diff --git a/tests/qemuxml2argvdata/arm-vexpressa9-basic.args b/tests/qemuxml2argvdata/arm-vexpressa9-basic.args index d9689b8ea8..1821ed4d38 100644 --- a/tests/qemuxml2argvdata/arm-vexpressa9-basic.args +++ b/tests/qemuxml2argvdata/arm-vexpressa9-basic.args @@ -27,7 +27,7 @@ server,nowait \ -dtb /arm.dtb \ -usb \ -drive file=/arm.raw,format=raw,if=sd,index=0 \ --net nic,macaddr=52:54:00:09:a4:37,vlan=0,model=lan9118,name=net0 \ --net user,vlan=0,name=hostnet0 \ +-netdev user,id=hostnet0 \ +-net nic,macaddr=52:54:00:09:a4:37,netdev=hostnet0,model=lan9118,name=net0 \ -chardev pty,id=charserial0 \ -serial chardev:charserial0