From nobody Thu Jul 3 17:58:40 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 152942647971263.3796978067179; Tue, 19 Jun 2018 09:41:19 -0700 (PDT) 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) 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 Content-Transfer-Encoding: quoted-printable 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) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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=3DX' 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(-) 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) =20 static char * qemuBuildLegacyNicStr(virDomainNetDefPtr net, - int vlan) + int vlan ATTRIBUTE_UNUSED) { char *str; char macaddr[VIR_MAC_STRING_BUFLEN]; =20 ignore_value(virAsprintf(&str, - "nic,macaddr=3D%s,vlan=3D%d%s%s%s%s", + "nic,macaddr=3D%s,netdev=3Dhost%s%s%s%s%s", virMacAddrFormat(&net->mac, macaddr), - vlan, + net->info.alias, (net->model ? ",model=3D" : ""), (net->model ? net->model : ""), (net->info.alias ? ",name=3D" : ""), @@ -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=3D%u", net->mtu); } =20 - if (vlan =3D=3D -1) - virBufferAsprintf(&buf, ",netdev=3Dhost%s", net->info.alias); - else - virBufferAsprintf(&buf, ",vlan=3D%d", vlan); + virBufferAsprintf(&buf, ",netdev=3Dhost%s", net->info.alias); virBufferAsprintf(&buf, ",id=3D%s", net->info.alias); virBufferAsprintf(&buf, ",mac=3D%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; } =20 - if (vlan >=3D 0) { - virBufferAsprintf(&buf, "vlan=3D%d,", vlan); - if (net->info.alias) - virBufferAsprintf(&buf, "name=3Dhost%s,", net->info.alias); - } else { - virBufferAsprintf(&buf, "id=3Dhost%s,", net->info.alias); - } + virBufferAsprintf(&buf, "id=3Dhost%s,", net->info.alias); =20 if (is_tap) { if (vhostfdSize) { @@ -8494,22 +8485,20 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driv= er, goto cleanup; } =20 + if (!(host =3D qemuBuildHostNetStr(net, driver, + vlan, + tapfdName, tapfdSize, + vhostfdName, vhostfdSize))) + goto cleanup; + virCommandAddArgList(cmd, "-netdev", host, NULL); + /* Possible combinations: * - * 1. Old way: -net nic,model=3De1000,vlan=3D1 -net tap,vlan=3D1 - * 2. New way: -netdev type=3Dtap,id=3Dnetdev1 -device e1000,id=3Dn= etdev1 - * - * NB: The backend and frontend are reversed above + * Old way: -netdev type=3Dtap,id=3Dnetdev1 \ + * -net nic,model=3De1000,netdev=3Dnetdev1 + * New way: -netdev type=3Dtap,id=3Dnetdev1 -device e1000,id=3Dnetde= v1 */ - if (qemuDomainSupportsNicdev(def, net)) { - if (!(host =3D qemuBuildHostNetStr(net, driver, - vlan, - tapfdName, tapfdSize, - vhostfdName, vhostfdSize))) - goto cleanup; - virCommandAddArgList(cmd, "-netdev", host, NULL); - if (!(nic =3D qemuBuildNicDevStr(def, net, vlan, bootindex, vhostfdSize, qemuCaps))) goto cleanup; @@ -8518,13 +8507,6 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr drive= r, if (!(nic =3D qemuBuildLegacyNicStr(net, vlan))) goto cleanup; virCommandAddArgList(cmd, "-net", nic, NULL); - - if (!(host =3D qemuBuildHostNetStr(net, driver, - vlan, - tapfdName, tapfdSize, - vhostfdName, vhostfdSize))) - goto cleanup; - virCommandAddArgList(cmd, "-net", host, NULL); } =20 ret =3D 0; diff --git a/tests/qemuxml2argvdata/arm-vexpressa9-basic.args b/tests/qemux= ml2argvdata/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=3D/arm.raw,format=3Draw,if=3Dsd,index=3D0 \ --net nic,macaddr=3D52:54:00:09:a4:37,vlan=3D0,model=3Dlan9118,name=3Dnet0 \ --net user,vlan=3D0,name=3Dhostnet0 \ +-netdev user,id=3Dhostnet0 \ +-net nic,macaddr=3D52:54:00:09:a4:37,netdev=3Dhostnet0,model=3Dlan9118,nam= e=3Dnet0 \ -chardev pty,id=3Dcharserial0 \ -serial chardev:charserial0 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list