From nobody Mon Feb 9 16:16:40 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579490702; cv=none; d=zohomail.com; s=zohoarc; b=LJTw4FYo4e7KscKKJEizeyw+1TddxeO+3egdXYymK4oGMY8KnuaaldEIOf30nGRKScIwhd62uaKwJ1pqrzriitw/oIV92DKoPZNgovlQx0PpPj22BrvtQhT4MaLaLksyUwBafDyEAN/x/NveT5kv/qjmCxpmVNarvqDSKLZnA5Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579490702; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TyeFcmMtgvNuO30VbmD+a936CnjgLV3jABw0DNm18cI=; b=h389rpnuQASkZbhJp6qDq+10uxW3VbvDCInWsH3Ur/HP0ALHohAz8XPFMTD6VaGshdVkGkcQouU7MgpNcABg3cx2l4kKr3o8O7dfu13XcbxITAR1EhDFsiiIN47CZb8D9t+uUHvwrohjZvES76AcrB1iID+y1cLgRiC+Ig/WA5c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1579490702690850.2262108954815; Sun, 19 Jan 2020 19:25:02 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-185-klaUCY5GPPqwiH3PisMNrw-1; Sun, 19 Jan 2020 22:24:59 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 45ABF107ACC7; Mon, 20 Jan 2020 03:24:54 +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 1E8DF39A; Mon, 20 Jan 2020 03:24:54 +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 D316B18089D6; Mon, 20 Jan 2020 03:24:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00K3OYY6002440 for ; Sun, 19 Jan 2020 22:24:34 -0500 Received: by smtp.corp.redhat.com (Postfix) id 06FF95C299; Mon, 20 Jan 2020 03:24:34 +0000 (UTC) Received: from tilapia.redhat.com (ovpn-121-72.rdu2.redhat.com [10.10.121.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5F17D5C1BB; Mon, 20 Jan 2020 03:24:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579490701; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=TyeFcmMtgvNuO30VbmD+a936CnjgLV3jABw0DNm18cI=; b=KAgtDLeSusXXOOOg9NOra2l+PUhrM6hlUq2QJJCNOQRsk4umT8MOJKgCRpuASmu5Pr02ut QphZJMKMAhAgSBLln8CJ0HlDzn0qBoeOhI/Zr6VRNFw+xU4upzyJrc3IQek3235F0lXKqo 0K4Np2i7bQlQDK46gef1l/083kF19bc= From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 08/12] conf: add backupAlias attribute to driver subelement Date: Sun, 19 Jan 2020 22:24:15 -0500 Message-Id: <20200120032419.448310-9-laine@redhat.com> In-Reply-To: <20200120032419.448310-1-laine@redhat.com> References: <20200120032419.448310-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Jens Freimann 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: klaUCY5GPPqwiH3PisMNrw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" For the subelement (including the backupAlias attribute) is parsed directly into the hostdev child object (virDomaniHostdevDef) of the interface (using virDomainHostdevDefParseXMLSubsys()). But for where the network is a pool of hostdevs, the hostdev object doesn't exist until the network port is allocated at runtime, and so virDomainHostdevDefParseXMLSubsys() can't be called during XML parsing, and any backupAlias in the driver subelement of the XML will be lost. For this case, we need to add a backupAlias member to the interface object (virDomainNetDef), and parse it during the parsing that happens for all non-hostdev interfaces. Then when the network port is allocated at runtime and the hostdev child object is created, we can copy the backupAlias into the hostdev so it is available when building the QEMU commandline. An example usage: Signed-off-by: Laine Stump --- src/conf/domain_conf.c | 11 ++++ src/conf/domain_conf.h | 1 + src/qemu/qemu_domain.c | 15 +++--- .../net-virtio-failover-network.xml | 37 ++++++++++++++ .../net-virtio-failover-network.xml | 51 +++++++++++++++++++ tests/qemuxml2xmltest.c | 3 ++ 6 files changed, 112 insertions(+), 6 deletions(-) create mode 100644 tests/qemuxml2argvdata/net-virtio-failover-network.xml create mode 100644 tests/qemuxml2xmloutdata/net-virtio-failover-network.xml diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e0e47415ed..89cccd22bc 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2428,6 +2428,7 @@ virDomainNetDefClear(virDomainNetDefPtr def) break; } =20 + VIR_FREE(def->driver.backupAlias); VIR_FREE(def->backend.tap); VIR_FREE(def->backend.vhost); VIR_FREE(def->virtPortProfile); @@ -11563,6 +11564,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, g_autofree char *localaddr =3D NULL; g_autofree char *localport =3D NULL; g_autofree char *model =3D NULL; + g_autofree char *backupAlias =3D NULL; g_autofree char *backend =3D NULL; g_autofree char *txmode =3D NULL; g_autofree char *ioeventfd =3D NULL; @@ -11735,6 +11737,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, } else if (virXMLNodeNameEqual(cur, "model")) { model =3D virXMLPropString(cur, "type"); } else if (virXMLNodeNameEqual(cur, "driver")) { + backupAlias =3D virXMLPropString(cur, "backupAlias"); backend =3D virXMLPropString(cur, "name"); txmode =3D virXMLPropString(cur, "txmode"); ioeventfd =3D virXMLPropString(cur, "ioeventfd"); @@ -12075,6 +12078,10 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlo= pt, * the subelement of has * already been parsed by virDomainHostdevDefParseXMLSubsys() */ + + if (backupAlias) + def->driver.backupAlias =3D g_steal_pointer(&backupAlias); + if (virDomainNetIsVirtioModel(def)) { if (backend !=3D NULL) { if ((val =3D virDomainNetBackendTypeFromString(backend)) <= 0 || @@ -25455,6 +25462,8 @@ virDomainNetDriverAttributesFormat(char **outstr, virDomainVirtioOptionsFormat(&buf, def->virtio); } =20 + virBufferEscapeString(&buf, " backupAlias=3D'%s'", def->driver.backupA= lias); + *outstr =3D virBufferContentAndReset(&buf); } =20 @@ -30675,6 +30684,8 @@ virDomainNetDefActualFromNetworkPort(virDomainNetDe= fPtr iface, } actual->data.hostdev.def.source.subsys.type =3D VIR_DOMAIN_HOSTDEV= _SUBSYS_TYPE_PCI; actual->data.hostdev.def.source.subsys.u.pci.addr =3D port->plug.h= ostdevpci.addr; + actual->data.hostdev.def.source.subsys.u.pci.backupAlias + =3D g_strdup(iface->driver.backupAlias); switch ((virNetworkForwardDriverNameType)port->plug.hostdevpci.dri= ver) { case VIR_NETWORK_FORWARD_DRIVER_NAME_DEFAULT: actual->data.hostdev.def.source.subsys.u.pci.backend =3D diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 0bf1d2b6bf..2b6d9bab75 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -929,6 +929,7 @@ struct _virDomainNetDef { int model; /* virDomainNetModelType */ char *modelstr; struct { + char *backupAlias; /* alias id of backup virtio device for failove= r */ union { struct { virDomainNetBackendType name; /* which driver backend to u= se */ diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index d32a3c0935..b8acbc6248 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -6472,13 +6472,16 @@ qemuDomainDeviceDefValidateNetwork(const virDomainN= etDef *net, _("tx_queue_size has to be a power of two")); return -1; } + } =20 - if (net->driver.virtio.failover =3D=3D VIR_TRISTATE_SWITCH_ON && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_FAILOVER)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("virtio-net failover is not supported with th= is QEMU binary")); - return -1; - } + + if ((net->driver.backupAlias || + (virDomainNetIsVirtioModel(net) && + net->driver.virtio.failover =3D=3D VIR_TRISTATE_SWITCH_ON)) && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_FAILOVER)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("virtio-net failover is not supported with this Q= EMU binary")); + return -1; } =20 if (net->mtu && diff --git a/tests/qemuxml2argvdata/net-virtio-failover-network.xml b/tests= /qemuxml2argvdata/net-virtio-failover-network.xml new file mode 100644 index 0000000000..e2674ed57d --- /dev/null +++ b/tests/qemuxml2argvdata/net-virtio-failover-network.xml @@ -0,0 +1,37 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i386 + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/qemuxml2xmloutdata/net-virtio-failover-network.xml b/tes= ts/qemuxml2xmloutdata/net-virtio-failover-network.xml new file mode 100644 index 0000000000..b803de1da2 --- /dev/null +++ b/tests/qemuxml2xmloutdata/net-virtio-failover-network.xml @@ -0,0 +1,51 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i386 + + + + +
+ + +
+ + + +
+ + + + + + + +
+ + + + + + +
+ + + + +
+ + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index c91690a030..45ba4db30c 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -454,6 +454,9 @@ mymain(void) DO_TEST("net-virtio-failover", QEMU_CAPS_VIRTIO_NET_FAILOVER, QEMU_CAPS_DEVICE_VFIO_PCI); + DO_TEST("net-virtio-failover-network", + QEMU_CAPS_VIRTIO_NET_FAILOVER, + QEMU_CAPS_DEVICE_VFIO_PCI); DO_TEST("net-hostdev", NONE); DO_TEST("net-hostdev-bootorder", NONE); DO_TEST("net-hostdev-vfio", QEMU_CAPS_DEVICE_VFIO_PCI); --=20 2.24.1