From nobody Mon Feb 9 23:14:41 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.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 205.139.110.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=1579490685; cv=none; d=zohomail.com; s=zohoarc; b=Uk9hsryL62prUKmfo3Nct6HmrPpOfg1QNNLyBMJcPgOcXN4/OVznvpoxBV2pklPUSfqIdkx16fEhQW0YEgaYxG0kc1R4J1+DBwbKi2SMU5N+RAuZdONue4j6duyAp3lPiI/azxUh6hZnLjx4+RhzYLNGhfthx2bCkegDTiA0LUI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579490685; 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=SgHChoTzSM5cnqZEmFV2KayfPvbHNO/9aqtCWT6dtSk=; b=CXmolgSz9N84mbaGbk8miBJVg0DR/VcD26EYwD0kye8PpdodfWF8Z1C5HS6uof9+EaHc/yuLkaYFo8Qm7IqLvyq0hH2sq6TQ1XSnY2UR4quDp/OzZhM62TBvXUuv544Vp6Z7/071X/R3TqfJ4EX+lQtQhGxFIK7CQuoqIDPYpYY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.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 [205.139.110.120]) by mx.zohomail.com with SMTPS id 1579490685125651.3132299644191; Sun, 19 Jan 2020 19:24:45 -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-114-SbDp9UCYPX2dvWW_X0XQzA-1; Sun, 19 Jan 2020 22:24:41 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5F7FBDB20; Mon, 20 Jan 2020 03:24:36 +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 BDD6E60C05; Mon, 20 Jan 2020 03:24:35 +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 CBE0418089CD; Mon, 20 Jan 2020 03:24:33 +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 00K3OWDs002429 for ; Sun, 19 Jan 2020 22:24:32 -0500 Received: by smtp.corp.redhat.com (Postfix) id 601B15C299; Mon, 20 Jan 2020 03:24:32 +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 B59205C1BB; Mon, 20 Jan 2020 03:24:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579490683; 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=SgHChoTzSM5cnqZEmFV2KayfPvbHNO/9aqtCWT6dtSk=; b=CbPA51TKk86yU7UVe2ETBlhkPBmSbaH2z8H1a/aw3MXZ/syY125UMNoCqHFG9icN+4KgvI 7dpEzWYWT0jfKcfuU1xlfqLf0HNhuG7Yos0IlUxXfHt5DrulyG8S1fWsHHmWXDKJe8gJel ICbGeAhDQKsP16++IFF33cMfXKmIQ3c= From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 06/12] conf: add failover attribute to subelement of Date: Sun, 19 Jan 2020 22:24:13 -0500 Message-Id: <20200120032419.448310-7-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.79 on 10.5.11.12 X-MC-Unique: SbDp9UCYPX2dvWW_X0XQzA-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" This attribute is only used for virtio-net devices, so it is stored in the virtio part of the anonymous union in virDomainNetDef::driver. An example of the new option: The corresponding qemu commandline option can only be set if the qemu binary supports it, so we check for the qemu capability before adding it. Signed-off-by: Laine Stump --- docs/schemas/domaincommon.rng | 5 ++ src/conf/domain_conf.c | 15 ++++++ src/conf/domain_conf.h | 1 + src/qemu/qemu_command.c | 3 ++ src/qemu/qemu_domain.c | 12 ++++- .../qemuxml2argvdata/net-virtio-failover.args | 36 +++++++++++++ .../qemuxml2argvdata/net-virtio-failover.xml | 36 +++++++++++++ tests/qemuxml2argvtest.c | 3 ++ .../net-virtio-failover.xml | 50 +++++++++++++++++++ tests/qemuxml2xmltest.c | 2 + 10 files changed, 161 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxml2argvdata/net-virtio-failover.args create mode 100644 tests/qemuxml2argvdata/net-virtio-failover.xml create mode 100644 tests/qemuxml2xmloutdata/net-virtio-failover.xml diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 76d94b156f..80aea47e36 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3050,6 +3050,11 @@ + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1379ae1600..29636617a2 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11558,6 +11558,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, g_autofree char *txmode =3D NULL; g_autofree char *ioeventfd =3D NULL; g_autofree char *event_idx =3D NULL; + g_autofree char *failover =3D NULL; g_autofree char *queues =3D NULL; g_autofree char *rx_queue_size =3D NULL; g_autofree char *tx_queue_size =3D NULL; @@ -11729,6 +11730,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, txmode =3D virXMLPropString(cur, "txmode"); ioeventfd =3D virXMLPropString(cur, "ioeventfd"); event_idx =3D virXMLPropString(cur, "event_idx"); + failover =3D virXMLPropString(cur, "failover"); queues =3D virXMLPropString(cur, "queues"); rx_queue_size =3D virXMLPropString(cur, "rx_queue_size"); tx_queue_size =3D virXMLPropString(cur, "tx_queue_size"); @@ -12105,6 +12107,15 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlo= pt, } def->driver.virtio.event_idx =3D val; } + if (failover) { + if ((val =3D virTristateSwitchTypeFromString(failover)) <= =3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown interface failover setting '= %s'"), + failover); + goto error; + } + def->driver.virtio.failover =3D val; + } if (queues) { unsigned int q; if (virStrToLong_uip(queues, NULL, 10, &q) < 0) { @@ -25416,6 +25427,10 @@ virDomainNetDriverAttributesFormat(char **outstr, virBufferAsprintf(&buf, " event_idx=3D'%s'", virTristateSwitchTypeToString(def->driver.vi= rtio.event_idx)); } + if (def->driver.virtio.failover) { + virBufferAsprintf(&buf, " failover=3D'%s'", + virTristateSwitchTypeToString(def->driver.vi= rtio.failover)); + } if (def->driver.virtio.queues) virBufferAsprintf(&buf, " queues=3D'%u'", def->driver.virtio.q= ueues); if (def->driver.virtio.rx_queue_size) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 5a44113681..af9691d62b 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -934,6 +934,7 @@ struct _virDomainNetDef { virDomainNetVirtioTxModeType txmode; virTristateSwitch ioeventfd; virTristateSwitch event_idx; + virTristateSwitch failover; unsigned int queues; /* Multiqueue virtio-net */ unsigned int rx_queue_size; unsigned int tx_queue_size; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 904d2beab5..d3c0cc0506 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3834,6 +3834,9 @@ qemuBuildNicDevStr(virDomainDefPtr def, virBufferAsprintf(&buf, ",host_mtu=3D%u", net->mtu); } =20 + if (usingVirtio && net->driver.virtio.failover =3D=3D VIR_TRISTATE_SWI= TCH_ON) + virBufferAddLit(&buf, ",failover=3Don"); + virBufferAsprintf(&buf, ",netdev=3Dhost%s", net->info.alias); virBufferAsprintf(&buf, ",id=3D%s", net->info.alias); virBufferAsprintf(&buf, ",mac=3D%s", diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index a6dde15bad..6f45d74bde 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -6396,7 +6396,8 @@ qemuDomainValidateActualNetDef(const virDomainNetDef = *net, =20 =20 static int -qemuDomainDeviceDefValidateNetwork(const virDomainNetDef *net) +qemuDomainDeviceDefValidateNetwork(const virDomainNetDef *net, + virQEMUCapsPtr qemuCaps) { bool hasIPv4 =3D false; bool hasIPv6 =3D false; @@ -6471,6 +6472,13 @@ qemuDomainDeviceDefValidateNetwork(const virDomainNe= tDef *net) _("tx_queue_size has to be a power of two")); return -1; } + + 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; + } } =20 if (net->mtu && @@ -8377,7 +8385,7 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef = *dev, =20 switch ((virDomainDeviceType)dev->type) { case VIR_DOMAIN_DEVICE_NET: - ret =3D qemuDomainDeviceDefValidateNetwork(dev->data.net); + ret =3D qemuDomainDeviceDefValidateNetwork(dev->data.net, qemuCaps= ); break; =20 case VIR_DOMAIN_DEVICE_CHR: diff --git a/tests/qemuxml2argvdata/net-virtio-failover.args b/tests/qemuxm= l2argvdata/net-virtio-failover.args new file mode 100644 index 0000000000..da41e19628 --- /dev/null +++ b/tests/qemuxml2argvdata/net-virtio-failover.args @@ -0,0 +1,36 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-QEMUGuest1 \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-i386 \ +-name QEMUGuest1 \ +-S \ +-machine pc,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff \ +-m 214 \ +-realtime mlock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-QEMUGuest1/moni= tor.sock,\ +server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-usb \ +-drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ +-device ide-hd,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0,b= ootindex=3D1 \ +-netdev user,id=3Dhostua-backup0 \ +-device virtio-net-pci,failover=3Don,netdev=3Dhostua-backup0,id=3Dua-backu= p0,\ +mac=3D00:11:22:33:44:55,bus=3Dpci.0,addr=3D0x3 \ +-netdev user,id=3Dhostua-backup1 \ +-device virtio-net-pci,failover=3Don,netdev=3Dhostua-backup1,id=3Dua-backu= p1,\ +mac=3D66:44:33:22:11:00,bus=3Dpci.0,addr=3D0x4 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x5 diff --git a/tests/qemuxml2argvdata/net-virtio-failover.xml b/tests/qemuxml= 2argvdata/net-virtio-failover.xml new file mode 100644 index 0000000000..1f545b8d73 --- /dev/null +++ b/tests/qemuxml2argvdata/net-virtio-failover.xml @@ -0,0 +1,36 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i386 + + + + + + + + + + + + + + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 58b4deefc6..c4fbe321d8 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1308,6 +1308,9 @@ mymain(void) QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SIZE, QEMU_CAPS_VIRTIO_NET_TX_QUEUE_SIZE); DO_TEST_PARSE_ERROR("net-virtio-rxqueuesize-invalid-size", NONE); + DO_TEST("net-virtio-failover", + QEMU_CAPS_VIRTIO_NET_FAILOVER); + DO_TEST_PARSE_ERROR("net-virtio-failover", NONE); DO_TEST("net-eth", NONE); DO_TEST("net-eth-ifname", NONE); DO_TEST("net-eth-names", NONE); diff --git a/tests/qemuxml2xmloutdata/net-virtio-failover.xml b/tests/qemux= ml2xmloutdata/net-virtio-failover.xml new file mode 100644 index 0000000000..7895c03dd7 --- /dev/null +++ b/tests/qemuxml2xmloutdata/net-virtio-failover.xml @@ -0,0 +1,50 @@ + + 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 3cefc64833..326e49fbcd 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -451,6 +451,8 @@ mymain(void) DO_TEST("net-eth-unmanaged-tap", NONE); DO_TEST("net-virtio-network-portgroup", NONE); DO_TEST("net-virtio-rxtxqueuesize", NONE); + DO_TEST("net-virtio-failover", + QEMU_CAPS_VIRTIO_NET_FAILOVER); 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