From nobody Sun Apr 28 07:16:05 2024 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.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1496850108547572.6129856705002; Wed, 7 Jun 2017 08:41:48 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9F61E1766BA; Wed, 7 Jun 2017 15:41:42 +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 3B8DB7DFFB; Wed, 7 Jun 2017 15:41:41 +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 2CA63180BAFA; Wed, 7 Jun 2017 15:41:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v57FfZOH029868 for ; Wed, 7 Jun 2017 11:41:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id F3E5617114; Wed, 7 Jun 2017 15:41:34 +0000 (UTC) Received: from moe.brq.redhat.com (dhcp129-131.brq.redhat.com [10.34.129.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E0EF7DFE8 for ; Wed, 7 Jun 2017 15:41:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9F61E1766BA Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9F61E1766BA From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 7 Jun 2017 17:41:29 +0200 Message-Id: <1a3571c3f36e4a40ab7fd8a995581fc4a1cc447d.1496850012.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/2] virsh: Accept iface alias for domifstats too 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 07 Jun 2017 15:41:44 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1459091 Not every interface has a name (for instance, vhostuser interfaces might not have one). However, all interfaces have aliases. We can accept those to uniquely identify interfaces. Signed-off-by: Michal Privoznik --- src/qemu/qemu_driver.c | 6 ++++-- tools/virsh-domain-monitor.c | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index f0cdea659..0634d9e5a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -10753,8 +10753,10 @@ qemuDomainInterfaceStats(virDomainPtr dom, =20 /* Check the path is one of the domain's network interfaces. */ for (i =3D 0; i < vm->def->nnets; i++) { - if (STREQ_NULLABLE(vm->def->nets[i]->ifname, path)) { - net =3D vm->def->nets[i]; + virDomainNetDefPtr tmp =3D vm->def->nets[i]; + if (STREQ_NULLABLE(tmp->ifname, path) || + STREQ(tmp->info.alias, path)) { + net =3D tmp; break; } } diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 0ca53e438..313a6d2f0 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -614,7 +614,8 @@ cmdDomiflist(vshControl *ctl, const vshCmd *cmd) "|./source/@network" "|./source/@name)", ctxt); =20 - target =3D virXPathString("string(./target/@dev)", ctxt); + target =3D virXPathString("string(./target/@dev" + "|./alias/@name)", ctxt); model =3D virXPathString("string(./model/@type)", ctxt); mac =3D virXPathString("string(./mac/@address)", ctxt); =20 --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 07:16:05 2024 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.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1496850127498843.1985741558788; Wed, 7 Jun 2017 08:42:07 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DF05680C20; Wed, 7 Jun 2017 15:42:05 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B291F7DFE9; Wed, 7 Jun 2017 15:42:05 +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 6C5114A48D; Wed, 7 Jun 2017 15:42:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v57FfZk1029873 for ; Wed, 7 Jun 2017 11:41:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id C56817DFE6; Wed, 7 Jun 2017 15:41:35 +0000 (UTC) Received: from moe.brq.redhat.com (dhcp129-131.brq.redhat.com [10.34.129.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4BED47DFEE for ; Wed, 7 Jun 2017 15:41:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DF05680C20 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com DF05680C20 From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 7 Jun 2017 17:41:30 +0200 Message-Id: <248ea0250372f4a4edcc3ee788b5b5e1d3d64b0c.1496850012.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/2] qemu: Query for vhostuser iface names at runtime 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 07 Jun 2017 15:42:06 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1459091 Currently, we are querying for vhostuser interface name in post parse callback. It doesn't hurt much, but at that time interface might not yet exist. However, it has to exist when starting domain. Therefore it makes more sense to query its name at that point. Signed-off-by: Michal Privoznik --- src/qemu/qemu_command.c | 4 +++ src/qemu/qemu_domain.c | 20 ++++--------- src/util/virnetdevopenvswitch.c | 1 + tests/Makefile.am | 7 ----- tests/qemuxml2xmlmock.c | 33 ------------------= ---- .../qemuxml2xmlout-net-vhostuser.xml | 2 -- tests/qemuxml2xmltest.c | 2 +- 7 files changed, 12 insertions(+), 57 deletions(-) delete mode 100644 tests/qemuxml2xmlmock.c diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 015af1036..44f778b7b 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -52,6 +52,7 @@ #include "secret_conf.h" #include "network/bridge_driver.h" #include "virnetdevtap.h" +#include "virnetdevopenvswitch.h" #include "device_conf.h" #include "virstoragefile.h" #include "virtpm.h" @@ -8310,6 +8311,9 @@ qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver, NULL, 0, NULL, 0))) goto error; =20 + if (virNetDevOpenvswitchGetVhostuserIfname(net->data.vhostuser->data.n= ix.path, + &net->ifname) < 0) + goto error; =20 virCommandAddArg(cmd, "-chardev"); virCommandAddArg(cmd, chardev); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 698632489..2d668f616 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3473,20 +3473,12 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr = dev, def->emulator); } =20 - if (dev->type =3D=3D VIR_DOMAIN_DEVICE_NET) { - if (dev->data.net->type !=3D VIR_DOMAIN_NET_TYPE_HOSTDEV && - !dev->data.net->model) { - if (VIR_STRDUP(dev->data.net->model, - qemuDomainDefaultNetModel(def, qemuCaps)) < 0) - goto cleanup; - } - if (dev->data.net->type =3D=3D VIR_DOMAIN_NET_TYPE_VHOSTUSER && - !dev->data.net->ifname) { - if (virNetDevOpenvswitchGetVhostuserIfname( - dev->data.net->data.vhostuser->data.nix.path, - &dev->data.net->ifname) < 0) - goto cleanup; - } + if (dev->type =3D=3D VIR_DOMAIN_DEVICE_NET && + dev->data.net->type !=3D VIR_DOMAIN_NET_TYPE_HOSTDEV && + !dev->data.net->model) { + if (VIR_STRDUP(dev->data.net->model, + qemuDomainDefaultNetModel(def, qemuCaps)) < 0) + goto cleanup; } =20 /* set default disk types and drivers */ diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitc= h.c index 42abcb4bb..8f7215e06 100644 --- a/src/util/virnetdevopenvswitch.c +++ b/src/util/virnetdevopenvswitch.c @@ -444,6 +444,7 @@ virNetDevOpenvswitchGetVhostuserIfname(const char *path, goto cleanup; } =20 + tmpIfname++; cmd =3D virCommandNew(OVSVSCTL); virNetDevOpenvswitchAddTimeout(cmd); virCommandAddArgList(cmd, "get", "Interface", tmpIfname, "name", NULL); diff --git a/tests/Makefile.am b/tests/Makefile.am index 7673329f2..19986dc99 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -288,7 +288,6 @@ test_helpers +=3D qemucapsprobe test_libraries +=3D libqemumonitortestutils.la \ libqemutestdriver.la \ qemuxml2argvmock.la \ - qemuxml2xmlmock.la \ qemucaps2xmlmock.la \ qemucapsprobemock.la \ qemucpumock.la \ @@ -575,12 +574,6 @@ qemuxml2argvmock_la_CFLAGS =3D $(AM_CFLAGS) qemuxml2argvmock_la_LDFLAGS =3D $(MOCKLIBS_LDFLAGS) qemuxml2argvmock_la_LIBADD =3D $(MOCKLIBS_LIBS) =20 -qemuxml2xmlmock_la_SOURCES =3D \ - qemuxml2xmlmock.c -qemuxml2xmlmock_la_CFLAGS =3D $(AM_CFLAGS) -qemuxml2xmlmock_la_LDFLAGS =3D $(MOCKLIBS_LDFLAGS) -qemuxml2xmlmock_la_LIBADD =3D $(MOCKLIBS_LIBS) - qemuxml2xmltest_SOURCES =3D \ qemuxml2xmltest.c testutilsqemu.c testutilsqemu.h \ testutils.c testutils.h diff --git a/tests/qemuxml2xmlmock.c b/tests/qemuxml2xmlmock.c deleted file mode 100644 index 0d3e6f2bd..000000000 --- a/tests/qemuxml2xmlmock.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2016 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * . - * - * Author: Michal Privoznik - */ - -#include - -#include "virnetdevopenvswitch.h" -#include "virstring.h" - -#define VIR_FROM_THIS VIR_FROM_NONE - -int -virNetDevOpenvswitchGetVhostuserIfname(const char *path ATTRIBUTE_UNUSED, - char **ifname) -{ - return VIR_STRDUP(*ifname, "vhost-user0"); -} diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-vhostuser.xml b/te= sts/qemuxml2xmloutdata/qemuxml2xmlout-net-vhostuser.xml index a4f4e4142..b7f1bdc57 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-vhostuser.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-vhostuser.xml @@ -30,14 +30,12 @@ -
-
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index fff13e236..6aececb59 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1142,7 +1142,7 @@ mymain(void) return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } =20 -VIR_TEST_MAIN_PRELOAD(mymain, abs_builddir "/.libs/qemuxml2xmlmock.so") +VIR_TEST_MAIN(mymain) =20 #else =20 --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list