[libvirt] [PATCHv2 0/7] qemu: add vhost-vsock-pci support

v1: https://www.redhat.com/archives/libvir-list/2018-May/msg01517.html v2: * use <vsock> instead of <interface> * use <source> for the guest address * add <source auto> attribute and auto-assign the guest CID * fixed PCI address allocation https://bugzilla.redhat.com/show_bug.cgi?id=1291851 Ján Tomko (7): Introduce virDomainVsockDef Add privateData to virDomainVsockDef conf: introduce <vsock> element qemu: add private data for vsock Introduce QEMU_CAPS_DEVICE_VHOST_VSOCK util: create virvsock.c qemu: add support for vhost-vsock-pci configure.ac | 8 + docs/formatdomain.html.in | 20 ++ docs/schemas/domaincommon.rng | 29 +++ src/conf/domain_conf.c | 228 ++++++++++++++++++++- src/conf/domain_conf.h | 27 +++ src/libvirt_private.syms | 6 + src/qemu/qemu_alias.c | 16 ++ src/qemu/qemu_capabilities.c | 2 + src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 45 ++++ src/qemu/qemu_domain.c | 42 ++++ src/qemu/qemu_domain.h | 9 + src/qemu/qemu_domain_address.c | 11 + src/qemu/qemu_driver.c | 6 + src/qemu/qemu_hotplug.c | 1 + src/qemu/qemu_process.c | 35 ++++ src/util/Makefile.inc.am | 2 + src/util/virvsock.c | 89 ++++++++ src/util/virvsock.h | 29 +++ tests/qemucapabilitiesdata/caps_2.10.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml | 1 + .../vhost-vsock-auto.x86_64-latest.args | 32 +++ tests/qemuxml2argvdata/vhost-vsock-auto.xml | 35 ++++ .../vhost-vsock.x86_64-latest.args | 32 +++ tests/qemuxml2argvdata/vhost-vsock.xml | 36 ++++ tests/qemuxml2argvtest.c | 14 ++ tests/qemuxml2xmloutdata/vhost-vsock-auto.xml | 36 ++++ tests/qemuxml2xmloutdata/vhost-vsock.xml | 1 + tests/qemuxml2xmltest.c | 3 + 41 files changed, 808 insertions(+), 1 deletion(-) create mode 100644 src/util/virvsock.c create mode 100644 src/util/virvsock.h create mode 100644 tests/qemuxml2argvdata/vhost-vsock-auto.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/vhost-vsock-auto.xml create mode 100644 tests/qemuxml2argvdata/vhost-vsock.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/vhost-vsock.xml create mode 100644 tests/qemuxml2xmloutdata/vhost-vsock-auto.xml create mode 120000 tests/qemuxml2xmloutdata/vhost-vsock.xml -- 2.16.1

A type to represent the new vsock device. Also implement an allocation function to allow future addition of private data. https://bugzilla.redhat.com/show_bug.cgi?id=1291851 Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/conf/domain_conf.c | 21 +++++++++++++++++++++ src/conf/domain_conf.h | 8 ++++++++ src/libvirt_private.syms | 1 + 3 files changed, 30 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3689ac0a82..5b4b182fd2 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2027,6 +2027,27 @@ virDomainActualNetDefFree(virDomainActualNetDefPtr def) VIR_FREE(def); } + +virDomainVsockDefPtr +virDomainVsockDefNew(virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED) +{ + virDomainVsockDefPtr ret = NULL; + virDomainVsockDefPtr vsock; + + if (VIR_ALLOC(vsock) < 0) + return NULL; + + VIR_STEAL_PTR(ret, vsock); + return ret; +} + + +void +virDomainVsockDefFree(virDomainVsockDefPtr vsock ATTRIBUTE_UNUSED) +{ +} + + void virDomainNetDefClear(virDomainNetDefPtr def) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index a78fdee40c..0eae14e732 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -157,6 +157,9 @@ typedef virDomainTPMDef *virDomainTPMDefPtr; typedef struct _virDomainIOMMUDef virDomainIOMMUDef; typedef virDomainIOMMUDef *virDomainIOMMUDefPtr; +typedef struct _virDomainVsockDef virDomainVsockDef; +typedef virDomainVsockDef *virDomainVsockDefPtr; + typedef struct _virDomainVirtioOptions virDomainVirtioOptions; typedef virDomainVirtioOptions *virDomainVirtioOptionsPtr; @@ -2310,6 +2313,9 @@ struct _virDomainIOMMUDef { virTristateSwitch iotlb; }; +struct _virDomainVsockDef { +}; + struct _virDomainVirtioOptions { virTristateSwitch iommu; virTristateSwitch ats; @@ -2788,6 +2794,8 @@ bool virDomainControllerIsPSeriesPHB(const virDomainControllerDef *cont); virDomainFSDefPtr virDomainFSDefNew(void); void virDomainFSDefFree(virDomainFSDefPtr def); void virDomainActualNetDefFree(virDomainActualNetDefPtr def); +virDomainVsockDefPtr virDomainVsockDefNew(virDomainXMLOptionPtr xmlopt); +void virDomainVsockDefFree(virDomainVsockDefPtr vsock); void virDomainNetDefClear(virDomainNetDefPtr def); void virDomainNetDefFree(virDomainNetDefPtr def); void virDomainSmartcardDefFree(virDomainSmartcardDefPtr def); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 3dece252df..8e33f3e9f6 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -573,6 +573,7 @@ virDomainVideoVGAConfTypeFromString; virDomainVideoVGAConfTypeToString; virDomainVirtTypeFromString; virDomainVirtTypeToString; +virDomainVsockDefNew; virDomainWatchdogActionTypeFromString; virDomainWatchdogActionTypeToString; virDomainWatchdogDefFree; -- 2.16.1

On Thu, May 24, 2018 at 12:39:09 +0200, Ján Tomko wrote:
A type to represent the new vsock device. Also implement an allocation function to allow future addition of private data.
https://bugzilla.redhat.com/show_bug.cgi?id=1291851
Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/conf/domain_conf.c | 21 +++++++++++++++++++++ src/conf/domain_conf.h | 8 ++++++++ src/libvirt_private.syms | 1 + 3 files changed, 30 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3689ac0a82..5b4b182fd2 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2027,6 +2027,27 @@ virDomainActualNetDefFree(virDomainActualNetDefPtr def) VIR_FREE(def); }
+ +virDomainVsockDefPtr +virDomainVsockDefNew(virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED) +{ + virDomainVsockDefPtr ret = NULL; + virDomainVsockDefPtr vsock; + + if (VIR_ALLOC(vsock) < 0) + return NULL; + + VIR_STEAL_PTR(ret, vsock); + return ret; +} + + +void +virDomainVsockDefFree(virDomainVsockDefPtr vsock ATTRIBUTE_UNUSED) +{
You should 'VIR_FREE(vsock)' here, as otherwise this does not do what the name suggests ...
+} + + void virDomainNetDefClear(virDomainNetDefPtr def)
ACK with the modification above

An object for storing driver-specific data in the vsock definition. https://bugzilla.redhat.com/show_bug.cgi?id=1291851 Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/conf/domain_conf.c | 16 ++++++++++++++-- src/conf/domain_conf.h | 2 ++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5b4b182fd2..b2982fc3d4 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2029,7 +2029,7 @@ virDomainActualNetDefFree(virDomainActualNetDefPtr def) virDomainVsockDefPtr -virDomainVsockDefNew(virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED) +virDomainVsockDefNew(virDomainXMLOptionPtr xmlopt) { virDomainVsockDefPtr ret = NULL; virDomainVsockDefPtr vsock; @@ -2037,14 +2037,26 @@ virDomainVsockDefNew(virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED) if (VIR_ALLOC(vsock) < 0) return NULL; + if (xmlopt && + xmlopt->privateData.vsockNew && + !(vsock->privateData = xmlopt->privateData.vsockNew())) + goto cleanup; + VIR_STEAL_PTR(ret, vsock); + cleanup: + virDomainVsockDefFree(vsock); return ret; } void -virDomainVsockDefFree(virDomainVsockDefPtr vsock ATTRIBUTE_UNUSED) +virDomainVsockDefFree(virDomainVsockDefPtr vsock) { + if (!vsock) + return; + + virObjectUnref(vsock->privateData); + vsock->privateData = NULL; } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 0eae14e732..4fa67ae7b7 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2314,6 +2314,7 @@ struct _virDomainIOMMUDef { }; struct _virDomainVsockDef { + virObjectPtr privateData; }; struct _virDomainVirtioOptions { @@ -2678,6 +2679,7 @@ struct _virDomainXMLPrivateDataCallbacks { virDomainXMLPrivateDataNewFunc diskNew; virDomainXMLPrivateDataNewFunc vcpuNew; virDomainXMLPrivateDataNewFunc chrSourceNew; + virDomainXMLPrivateDataNewFunc vsockNew; virDomainXMLPrivateDataFormatFunc format; virDomainXMLPrivateDataParseFunc parse; virDomainXMLPrivateDataStorageSourceParseFunc storageParse; -- 2.16.1

Add 'conf:' prefix. On Thu, May 24, 2018 at 12:39:10 +0200, Ján Tomko wrote:
An object for storing driver-specific data in the vsock definition.
https://bugzilla.redhat.com/show_bug.cgi?id=1291851 Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/conf/domain_conf.c | 16 ++++++++++++++-- src/conf/domain_conf.h | 2 ++ 2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5b4b182fd2..b2982fc3d4 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2029,7 +2029,7 @@ virDomainActualNetDefFree(virDomainActualNetDefPtr def)
virDomainVsockDefPtr -virDomainVsockDefNew(virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED) +virDomainVsockDefNew(virDomainXMLOptionPtr xmlopt) { virDomainVsockDefPtr ret = NULL; virDomainVsockDefPtr vsock; @@ -2037,14 +2037,26 @@ virDomainVsockDefNew(virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED) if (VIR_ALLOC(vsock) < 0) return NULL;
+ if (xmlopt && + xmlopt->privateData.vsockNew && + !(vsock->privateData = xmlopt->privateData.vsockNew())) + goto cleanup; + VIR_STEAL_PTR(ret, vsock); + cleanup: + virDomainVsockDefFree(vsock);
This will leak the struct if you don't do what I've suggested before. ACK

Add a new 'vsock' element for the vsock device. The 'model' attribute is optional. A <source cid> subelement should be used to specify the guest cid, or <source auto='yes'/> should be used. https://bugzilla.redhat.com/show_bug.cgi?id=1291851 --- docs/formatdomain.html.in | 20 +++ docs/schemas/domaincommon.rng | 29 ++++ src/conf/domain_conf.c | 195 +++++++++++++++++++++++++- src/conf/domain_conf.h | 17 +++ src/qemu/qemu_domain.c | 1 + src/qemu/qemu_domain_address.c | 11 ++ src/qemu/qemu_driver.c | 6 + src/qemu/qemu_hotplug.c | 1 + tests/qemuxml2argvdata/vhost-vsock-auto.xml | 35 +++++ tests/qemuxml2argvdata/vhost-vsock.xml | 36 +++++ tests/qemuxml2xmloutdata/vhost-vsock-auto.xml | 36 +++++ tests/qemuxml2xmloutdata/vhost-vsock.xml | 1 + tests/qemuxml2xmltest.c | 3 + 13 files changed, 390 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/vhost-vsock-auto.xml create mode 100644 tests/qemuxml2argvdata/vhost-vsock.xml create mode 100644 tests/qemuxml2xmloutdata/vhost-vsock-auto.xml create mode 120000 tests/qemuxml2xmloutdata/vhost-vsock.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 0d0fd3b9f3..bfe7f757b8 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -8133,6 +8133,26 @@ qemu-kvm -net nic,model=? /dev/null </dd> </dl> + <h3><a id="vsock">Vsock</a></h3> + + <p>A vsock host/guest interface. The <code>model</code> attribute + defaults to <code>virtio</code>. + The optional attribute <code>cid</code> of the source element + specifies the CID assigned to the guest. If the attribute + <code>auto</code> is set to <code>yes</code>, libvirt + will assign a free CID automatically on domain startup. + <span class="since">Since 4.4.0</span></p> + +<pre> +... +<devices> + <vsock model='virtio'> + <source auto='no' cid='3'/> + </vsock> +</devices> +...</pre> + + <h3><a id="seclabel">Security label</a></h3> <p> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 71ac3d079c..3ea5c91773 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4140,6 +4140,32 @@ </optional> </define> + <define name="vsock"> + <element name="vsock"> + <optional> + <attribute name="model"> + <value>virtio</value> + </attribute> + </optional> + <interleave> + <element name="source"> + <optional> + <attribute name="auto"> + <ref name="virYesNo"/> + </attribute> + </optional> + <optional> + <attribute name="cid"> + <ref name="unsignedInt"/> + </attribute> + </optional> + </element> + <optional> + <ref name="address"/> + </optional> + </interleave> + </element> + </define> <define name="iommu"> <element name="iommu"> <attribute name="model"> @@ -4687,6 +4713,9 @@ <optional> <ref name="iommu"/> </optional> + <optional> + <ref name="vsock"/> + </optional> </interleave> </element> </define> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b2982fc3d4..1a3dbf884b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -256,7 +256,8 @@ VIR_ENUM_IMPL(virDomainDevice, VIR_DOMAIN_DEVICE_LAST, "tpm", "panic", "memory", - "iommu") + "iommu", + "vsock") VIR_ENUM_IMPL(virDomainDeviceAddress, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST, "none", @@ -869,6 +870,10 @@ VIR_ENUM_IMPL(virDomainTPMBackend, VIR_DOMAIN_TPM_TYPE_LAST, VIR_ENUM_IMPL(virDomainIOMMUModel, VIR_DOMAIN_IOMMU_MODEL_LAST, "intel") +VIR_ENUM_IMPL(virDomainVsockModel, VIR_DOMAIN_VSOCK_MODEL_LAST, + "default", + "virtio") + VIR_ENUM_IMPL(virDomainDiskDiscard, VIR_DOMAIN_DISK_DISCARD_LAST, "default", "unmap", @@ -2777,6 +2782,9 @@ void virDomainDeviceDefFree(virDomainDeviceDefPtr def) case VIR_DOMAIN_DEVICE_IOMMU: VIR_FREE(def->data.iommu); break; + case VIR_DOMAIN_DEVICE_VSOCK: + virDomainVsockDefFree(def->data.vsock); + break; case VIR_DOMAIN_DEVICE_LAST: case VIR_DOMAIN_DEVICE_NONE: break; @@ -3641,6 +3649,8 @@ virDomainDeviceGetInfo(virDomainDeviceDefPtr device) return &device->data.panic->info; case VIR_DOMAIN_DEVICE_MEMORY: return &device->data.memory->info; + case VIR_DOMAIN_DEVICE_VSOCK: + return &device->data.vsock->info; /* The following devices do not contain virDomainDeviceInfo */ case VIR_DOMAIN_DEVICE_LEASE: @@ -3838,6 +3848,12 @@ virDomainDeviceInfoIterateInternal(virDomainDefPtr def, return rc; } + if (def->vsock) { + device.type = VIR_DOMAIN_DEVICE_VSOCK; + if ((rc = cb(def, &device, &def->vsock->info, opaque)) != 0) + return rc; + } + /* Coverity is not very happy with this - all dead_error_condition */ #if !STATIC_ANALYSIS /* This switch statement is here to trigger compiler warning when adding @@ -3872,6 +3888,7 @@ virDomainDeviceInfoIterateInternal(virDomainDefPtr def, case VIR_DOMAIN_DEVICE_RNG: case VIR_DOMAIN_DEVICE_MEMORY: case VIR_DOMAIN_DEVICE_IOMMU: + case VIR_DOMAIN_DEVICE_VSOCK: break; } #endif @@ -5575,6 +5592,19 @@ virDomainMemoryDefValidate(const virDomainMemoryDef *mem) } +static int +virDomainVsockDefValidate(const virDomainVsockDef *vsock) +{ + if (vsock->guest_cid > 0 && vsock->guest_cid <= 2) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("guest CIDs must be >= 3")); + return -1; + } + + return 0; +} + + static int virDomainDeviceDefValidateInternal(const virDomainDeviceDef *dev, const virDomainDef *def) @@ -5610,6 +5640,9 @@ virDomainDeviceDefValidateInternal(const virDomainDeviceDef *dev, case VIR_DOMAIN_DEVICE_MEMORY: return virDomainMemoryDefValidate(dev->data.memory); + case VIR_DOMAIN_DEVICE_VSOCK: + return virDomainVsockDefValidate(dev->data.vsock); + case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_FS: case VIR_DOMAIN_DEVICE_INPUT: @@ -15878,6 +15911,68 @@ virDomainIOMMUDefParseXML(xmlNodePtr node, } +static virDomainVsockDefPtr +virDomainVsockDefParseXML(virDomainXMLOptionPtr xmlopt, + xmlNodePtr node, + xmlXPathContextPtr ctxt, + unsigned int flags) +{ + virDomainVsockDefPtr vsock = NULL, ret = NULL; + xmlNodePtr save = ctxt->node; + xmlNodePtr source; + char *tmp = NULL; + int val; + + ctxt->node = node; + + if (!(vsock = virDomainVsockDefNew(xmlopt))) + goto cleanup; + + if ((tmp = virXMLPropString(node, "model"))) { + if ((val = virDomainVsockModelTypeFromString(tmp)) < 0) { + virReportError(VIR_ERR_XML_ERROR, _("unknown vsock model: %s"), tmp); + goto cleanup; + } + vsock->model = val; + } + + source = virXPathNode("./source", ctxt); + + VIR_FREE(tmp); + if (source && (tmp = virXMLPropString(source, "cid"))) { + if (virStrToLong_uip(tmp, NULL, 10, &vsock->guest_cid) < 0 || + vsock->guest_cid == 0) { + virReportError(VIR_ERR_XML_DETAIL, + _("'cid' attribute must be a positive number: %s"), + tmp); + goto cleanup; + } + } + + VIR_FREE(tmp); + if (source && (tmp = virXMLPropString(source, "auto"))) { + val = virTristateBoolTypeFromString(tmp); + if (val < 0) { + virReportError(VIR_ERR_XML_DETAIL, + _("'auto' attribute can be 'yes' or 'no': %s"), + tmp); + goto cleanup; + } + vsock->auto_cid = val; + } + + if (virDomainDeviceInfoParseXML(xmlopt, node, NULL, &vsock->info, flags) < 0) + goto cleanup; + + VIR_STEAL_PTR(ret, vsock); + + cleanup: + ctxt->node = save; + VIR_FREE(vsock); + VIR_FREE(tmp); + return ret; +} + virDomainDeviceDefPtr virDomainDeviceDefParse(const char *xmlStr, const virDomainDef *def, @@ -16033,6 +16128,11 @@ virDomainDeviceDefParse(const char *xmlStr, if (!(dev->data.iommu = virDomainIOMMUDefParseXML(node, ctxt))) goto error; break; + case VIR_DOMAIN_DEVICE_VSOCK: + if (!(dev->data.vsock = virDomainVsockDefParseXML(xmlopt, node, ctxt, + flags))) + goto error; + break; case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_LAST: break; @@ -20435,6 +20535,22 @@ virDomainDefParseXML(xmlDocPtr xml, } VIR_FREE(nodes); + if ((n = virXPathNodeSet("./devices/vsock", ctxt, &nodes)) < 0) + goto error; + + if (n > 1) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("only a single vsock device is supported")); + goto error; + } + + if (n > 0) { + if (!(def->vsock = virDomainVsockDefParseXML(xmlopt, nodes[0], + ctxt, flags))) + goto error; + } + VIR_FREE(nodes); + /* analysis of the user namespace mapping */ if ((n = virXPathNodeSet("./idmap/uid", ctxt, &nodes)) < 0) goto error; @@ -21996,6 +22112,26 @@ virDomainIOMMUDefCheckABIStability(virDomainIOMMUDefPtr src, } +static bool +virDomainVsockDefCheckABIStability(virDomainVsockDefPtr src, + virDomainVsockDefPtr dst) +{ + if (src->model != dst->model) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain vsock device model '%s' " + "does not match source '%s'"), + virDomainVsockModelTypeToString(dst->model), + virDomainVsockModelTypeToString(src->model)); + return false; + } + + if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info)) + return false; + + return true; +} + + static bool virDomainDefVcpuCheckAbiStability(virDomainDefPtr src, virDomainDefPtr dst) @@ -22441,6 +22577,17 @@ virDomainDefCheckABIStabilityFlags(virDomainDefPtr src, !virDomainIOMMUDefCheckABIStability(src->iommu, dst->iommu)) goto error; + if (!!src->vsock != !!dst->vsock) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Target domain vsock device count " + "does not match source")); + goto error; + } + + if (src->vsock && + !virDomainVsockDefCheckABIStability(src->vsock, dst->vsock)) + goto error; + if (xmlopt && xmlopt->abi.domain && !xmlopt->abi.domain(src, dst)) goto error; @@ -22478,6 +22625,7 @@ virDomainDefCheckABIStabilityFlags(virDomainDefPtr src, case VIR_DOMAIN_DEVICE_SHMEM: case VIR_DOMAIN_DEVICE_MEMORY: case VIR_DOMAIN_DEVICE_IOMMU: + case VIR_DOMAIN_DEVICE_VSOCK: break; } #endif @@ -26735,6 +26883,46 @@ virDomainMemtuneFormat(virBufferPtr buf, } +static int +virDomainVsockDefFormat(virBufferPtr buf, + virDomainVsockDefPtr vsock) +{ + virBuffer childBuf = VIR_BUFFER_INITIALIZER; + virBuffer attrBuf = VIR_BUFFER_INITIALIZER; + virBuffer sourceAttrBuf = VIR_BUFFER_INITIALIZER; + int ret = -1; + + if (vsock->model) { + virBufferAsprintf(&attrBuf, " model='%s'", + virDomainVsockModelTypeToString(vsock->model)); + } + + virBufferSetChildIndent(&childBuf, buf); + + if (vsock->auto_cid != VIR_TRISTATE_BOOL_ABSENT) { + virBufferAsprintf(&sourceAttrBuf, " auto='%s'", + virTristateBoolTypeToString(vsock->auto_cid)); + } + if (vsock->guest_cid != 0) + virBufferAsprintf(&sourceAttrBuf, " cid='%u'", vsock->guest_cid); + if (virXMLFormatElement(&childBuf, "source", &sourceAttrBuf, NULL) < 0) + goto cleanup; + + virDomainDeviceInfoFormat(&childBuf, &vsock->info, 0); + + if (virXMLFormatElement(buf, "vsock", &attrBuf, &childBuf) < 0) + goto cleanup; + + ret = 0; + + cleanup: + virBufferFreeAndReset(&childBuf); + virBufferFreeAndReset(&attrBuf); + virBufferFreeAndReset(&sourceAttrBuf); + return ret; +} + + /* This internal version appends to an existing buffer * (possibly with auto-indent), rather than flattening * to string. @@ -27469,6 +27657,10 @@ virDomainDefFormatInternal(virDomainDefPtr def, virDomainIOMMUDefFormat(buf, def->iommu) < 0) goto error; + if (def->vsock && + virDomainVsockDefFormat(buf, def->vsock) < 0) + goto error; + virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "</devices>\n"); @@ -28595,6 +28787,7 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src, case VIR_DOMAIN_DEVICE_MEMBALLOON: case VIR_DOMAIN_DEVICE_NVRAM: case VIR_DOMAIN_DEVICE_IOMMU: + case VIR_DOMAIN_DEVICE_VSOCK: case VIR_DOMAIN_DEVICE_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, _("Copying definition of '%d' type " diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 4fa67ae7b7..a5e45bfda5 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -189,6 +189,7 @@ typedef enum { VIR_DOMAIN_DEVICE_PANIC, VIR_DOMAIN_DEVICE_MEMORY, VIR_DOMAIN_DEVICE_IOMMU, + VIR_DOMAIN_DEVICE_VSOCK, VIR_DOMAIN_DEVICE_LAST } virDomainDeviceType; @@ -221,6 +222,7 @@ struct _virDomainDeviceDef { virDomainPanicDefPtr panic; virDomainMemoryDefPtr memory; virDomainIOMMUDefPtr iommu; + virDomainVsockDefPtr vsock; } data; }; @@ -2313,8 +2315,21 @@ struct _virDomainIOMMUDef { virTristateSwitch iotlb; }; +typedef enum { + VIR_DOMAIN_VSOCK_MODEL_DEFAULT, + VIR_DOMAIN_VSOCK_MODEL_VIRTIO, + + VIR_DOMAIN_VSOCK_MODEL_LAST +} virDomainVsockModel; + struct _virDomainVsockDef { virObjectPtr privateData; + + virDomainVsockModel model; + unsigned int guest_cid; + virTristateBool auto_cid; + + virDomainDeviceInfo info; }; struct _virDomainVirtioOptions { @@ -2462,6 +2477,7 @@ struct _virDomainDef { virSysinfoDefPtr sysinfo; virDomainRedirFilterDefPtr redirfilter; virDomainIOMMUDefPtr iommu; + virDomainVsockDefPtr vsock; void *namespaceData; virDomainXMLNamespace ns; @@ -3366,6 +3382,7 @@ VIR_ENUM_DECL(virDomainMemoryBackingModel) VIR_ENUM_DECL(virDomainMemorySource) VIR_ENUM_DECL(virDomainMemoryAllocation) VIR_ENUM_DECL(virDomainIOMMUModel) +VIR_ENUM_DECL(virDomainVsockModel) VIR_ENUM_DECL(virDomainShmemModel) /* from libvirt.h */ VIR_ENUM_DECL(virDomainState) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index d3beee5d87..6648933c80 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5132,6 +5132,7 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev, case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_PANIC: case VIR_DOMAIN_DEVICE_IOMMU: + case VIR_DOMAIN_DEVICE_VSOCK: case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_LAST: break; diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index b7c82cb6f1..e9f460d77a 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -859,6 +859,9 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, } break; + case VIR_DOMAIN_DEVICE_VSOCK: + return virtioFlags; + /* These devices don't ever connect with PCI */ case VIR_DOMAIN_DEVICE_NVRAM: case VIR_DOMAIN_DEVICE_TPM: @@ -2152,6 +2155,14 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def, /* Nada - none are PCI based (yet) */ } + if (def->vsock && + virDeviceInfoPCIAddressWanted(&def->vsock->info)) { + + if (qemuDomainPCIAddressReserveNextAddr(addrs, + &def->vsock->info) < 0) + goto error; + } + return 0; error: diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 3a328e5d46..9d5cf4d61a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7701,6 +7701,7 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm, case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_PANIC: case VIR_DOMAIN_DEVICE_IOMMU: + case VIR_DOMAIN_DEVICE_VSOCK: case VIR_DOMAIN_DEVICE_LAST: virReportError(VIR_ERR_OPERATION_UNSUPPORTED, _("live attach of device '%s' is not supported"), @@ -7800,6 +7801,7 @@ qemuDomainDetachDeviceLive(virDomainObjPtr vm, case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_PANIC: case VIR_DOMAIN_DEVICE_IOMMU: + case VIR_DOMAIN_DEVICE_VSOCK: case VIR_DOMAIN_DEVICE_LAST: virReportError(VIR_ERR_OPERATION_UNSUPPORTED, _("live detach of device '%s' is not supported"), @@ -7936,6 +7938,7 @@ qemuDomainUpdateDeviceLive(virDomainObjPtr vm, case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_PANIC: case VIR_DOMAIN_DEVICE_IOMMU: + case VIR_DOMAIN_DEVICE_VSOCK: case VIR_DOMAIN_DEVICE_LAST: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("live update of device '%s' is not supported"), @@ -8122,6 +8125,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_PANIC: case VIR_DOMAIN_DEVICE_IOMMU: + case VIR_DOMAIN_DEVICE_VSOCK: case VIR_DOMAIN_DEVICE_LAST: virReportError(VIR_ERR_OPERATION_UNSUPPORTED, _("persistent attach of device '%s' is not supported"), @@ -8305,6 +8309,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef, case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_PANIC: case VIR_DOMAIN_DEVICE_IOMMU: + case VIR_DOMAIN_DEVICE_VSOCK: case VIR_DOMAIN_DEVICE_LAST: virReportError(VIR_ERR_OPERATION_UNSUPPORTED, _("persistent detach of device '%s' is not supported"), @@ -8403,6 +8408,7 @@ qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef, case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_PANIC: case VIR_DOMAIN_DEVICE_IOMMU: + case VIR_DOMAIN_DEVICE_VSOCK: case VIR_DOMAIN_DEVICE_LAST: virReportError(VIR_ERR_OPERATION_UNSUPPORTED, _("persistent update of device '%s' is not supported"), diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index b35594be5f..e429f54a43 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -4626,6 +4626,7 @@ qemuDomainRemoveDevice(virQEMUDriverPtr driver, case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_PANIC: case VIR_DOMAIN_DEVICE_IOMMU: + case VIR_DOMAIN_DEVICE_VSOCK: case VIR_DOMAIN_DEVICE_LAST: virReportError(VIR_ERR_OPERATION_UNSUPPORTED, _("don't know how to remove a %s device"), diff --git a/tests/qemuxml2argvdata/vhost-vsock-auto.xml b/tests/qemuxml2argvdata/vhost-vsock-auto.xml new file mode 100644 index 0000000000..729d58bea4 --- /dev/null +++ b/tests/qemuxml2argvdata/vhost-vsock-auto.xml @@ -0,0 +1,35 @@ +<domain type='qemu'> + <name>test</name> + <uuid>bba65c0e-c049-934f-b6aa-4e2c0582acdf</uuid> + <memory unit='KiB'>1048576</memory> + <currentMemory unit='KiB'>1048576</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='x86_64' machine='pc-0.13'>hvm</type> + <boot dev='hd'/> + <bootmenu enable='yes'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>restart</on_crash> + <devices> + <emulator>/usr/bin/qemu-system-x86_64</emulator> + <controller type='usb' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='virtio-serial' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/> + </controller> + <controller type='ide' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <memballoon model='none'/> + <vsock> + <source auto='yes'/> + </vsock> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/vhost-vsock.xml b/tests/qemuxml2argvdata/vhost-vsock.xml new file mode 100644 index 0000000000..ac210cb116 --- /dev/null +++ b/tests/qemuxml2argvdata/vhost-vsock.xml @@ -0,0 +1,36 @@ +<domain type='qemu'> + <name>test</name> + <uuid>bba65c0e-c049-934f-b6aa-4e2c0582acdf</uuid> + <memory unit='KiB'>1048576</memory> + <currentMemory unit='KiB'>1048576</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='x86_64' machine='pc-0.13'>hvm</type> + <boot dev='hd'/> + <bootmenu enable='yes'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>restart</on_crash> + <devices> + <emulator>/usr/bin/qemu-system-x86_64</emulator> + <controller type='usb' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='virtio-serial' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/> + </controller> + <controller type='ide' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <memballoon model='none'/> + <vsock model='virtio'> + <source cid='4'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> + </vsock> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/vhost-vsock-auto.xml b/tests/qemuxml2xmloutdata/vhost-vsock-auto.xml new file mode 100644 index 0000000000..65f18b96d9 --- /dev/null +++ b/tests/qemuxml2xmloutdata/vhost-vsock-auto.xml @@ -0,0 +1,36 @@ +<domain type='qemu'> + <name>test</name> + <uuid>bba65c0e-c049-934f-b6aa-4e2c0582acdf</uuid> + <memory unit='KiB'>1048576</memory> + <currentMemory unit='KiB'>1048576</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='x86_64' machine='pc-0.13'>hvm</type> + <boot dev='hd'/> + <bootmenu enable='yes'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>restart</on_crash> + <devices> + <emulator>/usr/bin/qemu-system-x86_64</emulator> + <controller type='usb' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='virtio-serial' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/> + </controller> + <controller type='ide' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <memballoon model='none'/> + <vsock> + <source auto='yes'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </vsock> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/vhost-vsock.xml b/tests/qemuxml2xmloutdata/vhost-vsock.xml new file mode 120000 index 0000000000..bb24241fb2 --- /dev/null +++ b/tests/qemuxml2xmloutdata/vhost-vsock.xml @@ -0,0 +1 @@ +../qemuxml2argvdata/vhost-vsock.xml \ No newline at end of file diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 7cedc2b999..cd6538a442 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1209,6 +1209,9 @@ mymain(void) DO_TEST_STATUS("migration-in-params"); DO_TEST_STATUS("migration-out-params"); + DO_TEST("vhost-vsock", NONE); + DO_TEST("vhost-vsock-auto", NONE); + if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL) virFileDeleteTree(fakerootdir); -- 2.16.1

On Thu, May 24, 2018 at 12:39:11 +0200, Ján Tomko wrote:
Add a new 'vsock' element for the vsock device. The 'model' attribute is optional. A <source cid> subelement should be used to specify the guest cid, or <source auto='yes'/> should be used.
https://bugzilla.redhat.com/show_bug.cgi?id=1291851 --- docs/formatdomain.html.in | 20 +++ docs/schemas/domaincommon.rng | 29 ++++ src/conf/domain_conf.c | 195 +++++++++++++++++++++++++- src/conf/domain_conf.h | 17 +++ src/qemu/qemu_domain.c | 1 + src/qemu/qemu_domain_address.c | 11 ++ src/qemu/qemu_driver.c | 6 + src/qemu/qemu_hotplug.c | 1 + tests/qemuxml2argvdata/vhost-vsock-auto.xml | 35 +++++ tests/qemuxml2argvdata/vhost-vsock.xml | 36 +++++ tests/qemuxml2xmloutdata/vhost-vsock-auto.xml | 36 +++++ tests/qemuxml2xmloutdata/vhost-vsock.xml | 1 + tests/qemuxml2xmltest.c | 3 + 13 files changed, 390 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/vhost-vsock-auto.xml create mode 100644 tests/qemuxml2argvdata/vhost-vsock.xml create mode 100644 tests/qemuxml2xmloutdata/vhost-vsock-auto.xml create mode 120000 tests/qemuxml2xmloutdata/vhost-vsock.xml
I've recently added a new swithc case which breaks with the following message: qemu/qemu_domain.c: In function 'qemuDomainDeviceDefPostParse': qemu/qemu_domain.c:5802:5: error: enumeration value 'VIR_DOMAIN_DEVICE_VSOCK' not handled in switch [-Werror=switch-enum] switch ((virDomainDeviceType) dev->type) { ^~~~~~ Apply the following patch: diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 527781c0fa..3e8e6358de 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5845,6 +5845,7 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_MEMORY: case VIR_DOMAIN_DEVICE_IOMMU: + case VIR_DOMAIN_DEVICE_VSOCK: ret = 0; break;
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 0d0fd3b9f3..bfe7f757b8 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -8133,6 +8133,26 @@ qemu-kvm -net nic,model=? /dev/null </dd> </dl>
+ <h3><a id="vsock">Vsock</a></h3> + + <p>A vsock host/guest interface. The <code>model</code> attribute + defaults to <code>virtio</code>. + The optional attribute <code>cid</code> of the source element + specifies the CID assigned to the guest. If the attribute + <code>auto</code> is set to <code>yes</code>, libvirt + will assign a free CID automatically on domain startup. + <span class="since">Since 4.4.0</span></p>
Should we perhaps mention some docs where users can figure out how to use it? Also please mention what the default value of 'auto' is. e.g. what the following definition actually configures: <vsock model='virtio'/>
+ +<pre> +... +<devices> + <vsock model='virtio'> + <source auto='no' cid='3'/> + </vsock> +</devices> +...</pre> + + <h3><a id="seclabel">Security label</a></h3>
<p> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 71ac3d079c..3ea5c91773 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4140,6 +4140,32 @@ </optional> </define>
+ <define name="vsock"> + <element name="vsock"> + <optional> + <attribute name="model"> + <value>virtio</value> + </attribute> + </optional> + <interleave> + <element name="source">
So, source is mandatory? It should be noted in the docs ...
+ <optional> + <attribute name="auto"> + <ref name="virYesNo"/> + </attribute> + </optional> + <optional> + <attribute name="cid"> + <ref name="unsignedInt"/> + </attribute> + </optional>
Also both attributes are optional which is kind of weird if <source> is mandatory.
+ </element> + <optional> + <ref name="address"/> + </optional> + </interleave> + </element> + </define>
[...]
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b2982fc3d4..1a3dbf884b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c
[...]
@@ -15878,6 +15911,68 @@ virDomainIOMMUDefParseXML(xmlNodePtr node, }
+static virDomainVsockDefPtr +virDomainVsockDefParseXML(virDomainXMLOptionPtr xmlopt, + xmlNodePtr node, + xmlXPathContextPtr ctxt, + unsigned int flags) +{ + virDomainVsockDefPtr vsock = NULL, ret = NULL; + xmlNodePtr save = ctxt->node; + xmlNodePtr source; + char *tmp = NULL; + int val; + + ctxt->node = node; + + if (!(vsock = virDomainVsockDefNew(xmlopt))) + goto cleanup; + + if ((tmp = virXMLPropString(node, "model"))) { + if ((val = virDomainVsockModelTypeFromString(tmp)) < 0) {
Model 'default' should not be allowed.
+ virReportError(VIR_ERR_XML_ERROR, _("unknown vsock model: %s"), tmp); + goto cleanup; + } + vsock->model = val; + } + + source = virXPathNode("./source", ctxt); + + VIR_FREE(tmp); + if (source && (tmp = virXMLPropString(source, "cid"))) {
'source' is the common condition in both if the statements below, so perhaps it can be extracted one level up.
+ if (virStrToLong_uip(tmp, NULL, 10, &vsock->guest_cid) < 0 || + vsock->guest_cid == 0) { + virReportError(VIR_ERR_XML_DETAIL, + _("'cid' attribute must be a positive number: %s"), + tmp); + goto cleanup; + } + } + + VIR_FREE(tmp); + if (source && (tmp = virXMLPropString(source, "auto"))) { + val = virTristateBoolTypeFromString(tmp); + if (val < 0) {
the "default" value should not be allowed ...
+ virReportError(VIR_ERR_XML_DETAIL, + _("'auto' attribute can be 'yes' or 'no': %s"),
... specifically given this error message.
+ tmp); + goto cleanup; + } + vsock->auto_cid = val; + } + + if (virDomainDeviceInfoParseXML(xmlopt, node, NULL, &vsock->info, flags) < 0) + goto cleanup; + + VIR_STEAL_PTR(ret, vsock); + + cleanup: + ctxt->node = save; + VIR_FREE(vsock); + VIR_FREE(tmp); + return ret; +}
[...]
@@ -28595,6 +28787,7 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src, case VIR_DOMAIN_DEVICE_MEMBALLOON: case VIR_DOMAIN_DEVICE_NVRAM: case VIR_DOMAIN_DEVICE_IOMMU: + case VIR_DOMAIN_DEVICE_VSOCK:
This should be very easy to implement. [...]
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index b35594be5f..e429f54a43 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -4626,6 +4626,7 @@ qemuDomainRemoveDevice(virQEMUDriverPtr driver, case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_PANIC: case VIR_DOMAIN_DEVICE_IOMMU: + case VIR_DOMAIN_DEVICE_VSOCK:
Note that I've did not look through the impl patch yet, so the below comment may be actually moot. At least this should be implemented as you can trigger a device detach from the guest as well. Since this does not have any backend data, the removal function is trivial.
case VIR_DOMAIN_DEVICE_LAST: virReportError(VIR_ERR_OPERATION_UNSUPPORTED, _("don't know how to remove a %s device"), diff --git a/tests/qemuxml2argvdata/vhost-vsock-auto.xml b/tests/qemuxml2argvdata/vhost-vsock-auto.xml new file mode 100644 index 0000000000..729d58bea4 --- /dev/null +++ b/tests/qemuxml2argvdata/vhost-vsock-auto.xml @@ -0,0 +1,35 @@ +<domain type='qemu'> + <name>test</name> + <uuid>bba65c0e-c049-934f-b6aa-4e2c0582acdf</uuid> + <memory unit='KiB'>1048576</memory> + <currentMemory unit='KiB'>1048576</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='x86_64' machine='pc-0.13'>hvm</type>
Our XMLs are living in the past.
+ <boot dev='hd'/> + <bootmenu enable='yes'/>
For an ACK please state how you plan to deal with the schema issues I've pointed out. All other necessary changes were pointed out.

On Tue, May 29, 2018 at 10:26:20AM +0200, Peter Krempa wrote:
On Thu, May 24, 2018 at 12:39:11 +0200, Ján Tomko wrote:
Add a new 'vsock' element for the vsock device. The 'model' attribute is optional. A <source cid> subelement should be used to specify the guest cid, or <source auto='yes'/> should be used.
https://bugzilla.redhat.com/show_bug.cgi?id=1291851 --- docs/formatdomain.html.in | 20 +++ docs/schemas/domaincommon.rng | 29 ++++ src/conf/domain_conf.c | 195 +++++++++++++++++++++++++- src/conf/domain_conf.h | 17 +++ src/qemu/qemu_domain.c | 1 + src/qemu/qemu_domain_address.c | 11 ++ src/qemu/qemu_driver.c | 6 + src/qemu/qemu_hotplug.c | 1 + tests/qemuxml2argvdata/vhost-vsock-auto.xml | 35 +++++ tests/qemuxml2argvdata/vhost-vsock.xml | 36 +++++ tests/qemuxml2xmloutdata/vhost-vsock-auto.xml | 36 +++++ tests/qemuxml2xmloutdata/vhost-vsock.xml | 1 + tests/qemuxml2xmltest.c | 3 + 13 files changed, 390 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/vhost-vsock-auto.xml create mode 100644 tests/qemuxml2argvdata/vhost-vsock.xml create mode 100644 tests/qemuxml2xmloutdata/vhost-vsock-auto.xml create mode 120000 tests/qemuxml2xmloutdata/vhost-vsock.xml
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 71ac3d079c..3ea5c91773 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4140,6 +4140,32 @@ </optional> </define>
+ <define name="vsock"> + <element name="vsock"> + <optional> + <attribute name="model"> + <value>virtio</value> + </attribute> + </optional> + <interleave> + <element name="source">
So, source is mandatory? It should be noted in the docs ...
+ <optional> + <attribute name="auto"> + <ref name="virYesNo"/> + </attribute> + </optional> + <optional> + <attribute name="cid"> + <ref name="unsignedInt"/> + </attribute> + </optional>
Also both attributes are optional which is kind of weird if <source> is mandatory.
+ </element> + <optional> + <ref name="address"/> + </optional> + </interleave> + </element> + </define>
[...]
[...]
diff --git a/tests/qemuxml2argvdata/vhost-vsock-auto.xml b/tests/qemuxml2argvdata/vhost-vsock-auto.xml new file mode 100644 index 0000000000..729d58bea4 --- /dev/null +++ b/tests/qemuxml2argvdata/vhost-vsock-auto.xml @@ -0,0 +1,35 @@ +<domain type='qemu'> + <name>test</name> + <uuid>bba65c0e-c049-934f-b6aa-4e2c0582acdf</uuid> + <memory unit='KiB'>1048576</memory> + <currentMemory unit='KiB'>1048576</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='x86_64' machine='pc-0.13'>hvm</type>
Our XMLs are living in the past.
+ <boot dev='hd'/> + <bootmenu enable='yes'/>
For an ACK please state how you plan to deal with the schema issues I've pointed out. All other necessary changes were pointed out.
The idea is to transform <vsock> -> <vsock model='virtio'/> in the QEMU driver. <source> and both of its attributes will be optional in the schema and in case 'auto' is missing, we'll tune it up in PostParse: if (vsock->auto_cid == VIR_TRISTATE_BOOL_ABSENT) { if (vsock->guest_cid != 0) vsock->auto_cid = VIR_TRISTATE_BOOL_NO; else vsock->auto_cid = VIR_TRISTATE_BOOL_YES; } Jano

On Tue, May 29, 2018 at 13:36:51 +0200, Ján Tomko wrote:
On Tue, May 29, 2018 at 10:26:20AM +0200, Peter Krempa wrote:
On Thu, May 24, 2018 at 12:39:11 +0200, Ján Tomko wrote:
Add a new 'vsock' element for the vsock device. The 'model' attribute is optional. A <source cid> subelement should be used to specify the guest cid, or <source auto='yes'/> should be used.
https://bugzilla.redhat.com/show_bug.cgi?id=1291851 --- docs/formatdomain.html.in | 20 +++ docs/schemas/domaincommon.rng | 29 ++++ src/conf/domain_conf.c | 195 +++++++++++++++++++++++++- src/conf/domain_conf.h | 17 +++ src/qemu/qemu_domain.c | 1 + src/qemu/qemu_domain_address.c | 11 ++ src/qemu/qemu_driver.c | 6 + src/qemu/qemu_hotplug.c | 1 + tests/qemuxml2argvdata/vhost-vsock-auto.xml | 35 +++++ tests/qemuxml2argvdata/vhost-vsock.xml | 36 +++++ tests/qemuxml2xmloutdata/vhost-vsock-auto.xml | 36 +++++ tests/qemuxml2xmloutdata/vhost-vsock.xml | 1 + tests/qemuxml2xmltest.c | 3 + 13 files changed, 390 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/vhost-vsock-auto.xml create mode 100644 tests/qemuxml2argvdata/vhost-vsock.xml create mode 100644 tests/qemuxml2xmloutdata/vhost-vsock-auto.xml create mode 120000 tests/qemuxml2xmloutdata/vhost-vsock.xml
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 71ac3d079c..3ea5c91773 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4140,6 +4140,32 @@ </optional> </define>
+ <define name="vsock"> + <element name="vsock"> + <optional> + <attribute name="model"> + <value>virtio</value> + </attribute> + </optional> + <interleave> + <element name="source">
So, source is mandatory? It should be noted in the docs ...
+ <optional> + <attribute name="auto"> + <ref name="virYesNo"/> + </attribute> + </optional> + <optional> + <attribute name="cid"> + <ref name="unsignedInt"/> + </attribute> + </optional>
Also both attributes are optional which is kind of weird if <source> is mandatory.
+ </element> + <optional> + <ref name="address"/> + </optional> + </interleave> + </element> + </define>
[...]
[...]
diff --git a/tests/qemuxml2argvdata/vhost-vsock-auto.xml b/tests/qemuxml2argvdata/vhost-vsock-auto.xml new file mode 100644 index 0000000000..729d58bea4 --- /dev/null +++ b/tests/qemuxml2argvdata/vhost-vsock-auto.xml @@ -0,0 +1,35 @@ +<domain type='qemu'> + <name>test</name> + <uuid>bba65c0e-c049-934f-b6aa-4e2c0582acdf</uuid> + <memory unit='KiB'>1048576</memory> + <currentMemory unit='KiB'>1048576</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='x86_64' machine='pc-0.13'>hvm</type>
Our XMLs are living in the past.
+ <boot dev='hd'/> + <bootmenu enable='yes'/>
For an ACK please state how you plan to deal with the schema issues I've pointed out. All other necessary changes were pointed out.
The idea is to transform <vsock> -> <vsock model='virtio'/> in the QEMU driver.
<source> and both of its attributes will be optional in the schema and in case 'auto' is missing, we'll tune it up in PostParse:
if (vsock->auto_cid == VIR_TRISTATE_BOOL_ABSENT) { if (vsock->guest_cid != 0) vsock->auto_cid = VIR_TRISTATE_BOOL_NO; else vsock->auto_cid = VIR_TRISTATE_BOOL_YES; }
Okay. ACK if you make <source> optional and add this code.

On Thu, May 24, 2018 at 12:39:11PM +0200, Ján Tomko wrote:
Add a new 'vsock' element for the vsock device. The 'model' attribute is optional. A <source cid> subelement should be used to specify the guest cid, or <source auto='yes'/> should be used.
I always find the <source> vs <target> naming somewhat confusing because we are not consistent in how we use them. How about just avoiding the term entirely eg similar to how we declare MAC with <mac address="...">: <cid address="3"/> optionally having auto=yes|no Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

Introduce a structure and a class that will be used to store the private data. https://bugzilla.redhat.com/show_bug.cgi?id=1291851 Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/qemu_domain.c | 36 ++++++++++++++++++++++++++++++++++++ src/qemu/qemu_domain.h | 9 +++++++++ 2 files changed, 45 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6648933c80..527abe3b63 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1134,6 +1134,41 @@ qemuDomainChrSourcePrivateDispose(void *obj) } +static virClassPtr qemuDomainVsockPrivateClass; +static void qemuDomainVsockPrivateDispose(void *obj); + +static int +qemuDomainVsockPrivateOnceInit(void) +{ + if (!VIR_CLASS_NEW(qemuDomainVsockPrivate, virClassForObject())) + return -1; + + return 0; +} + +VIR_ONCE_GLOBAL_INIT(qemuDomainVsockPrivate) + +static virObjectPtr +qemuDomainVsockPrivateNew(void) +{ + qemuDomainVsockPrivatePtr priv; + + if (qemuDomainVsockPrivateInitialize() < 0) + return NULL; + + if (!(priv = virObjectNew(qemuDomainVsockPrivateClass))) + return NULL; + + return (virObjectPtr) priv; +} + + +static void +qemuDomainVsockPrivateDispose(void *obj ATTRIBUTE_UNUSED) +{ +} + + /* qemuDomainSecretPlainSetup: * @secinfo: Pointer to secret info * @usageType: The virSecretUsageType @@ -2636,6 +2671,7 @@ virDomainXMLPrivateDataCallbacks virQEMUDriverPrivateDataCallbacks = { .diskNew = qemuDomainDiskPrivateNew, .vcpuNew = qemuDomainVcpuPrivateNew, .chrSourceNew = qemuDomainChrSourcePrivateNew, + .vsockNew = qemuDomainVsockPrivateNew, .parse = qemuDomainObjPrivateXMLParse, .format = qemuDomainObjPrivateXMLFormat, .storageParse = qemuStorageSourcePrivateDataParse, diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 40d1d095a3..2046741a17 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -441,6 +441,15 @@ struct _qemuDomainChrSourcePrivate { }; +typedef struct _qemuDomainVsockPrivate qemuDomainVsockPrivate; +typedef qemuDomainVsockPrivate *qemuDomainVsockPrivatePtr; +struct _qemuDomainVsockPrivate { + virObject parent; + + virTristateBool maybe; +}; + + typedef enum { QEMU_PROCESS_EVENT_WATCHDOG = 0, QEMU_PROCESS_EVENT_GUESTPANIC, -- 2.16.1

On Thu, May 24, 2018 at 12:39:12 +0200, Ján Tomko wrote:
Introduce a structure and a class that will be used to store the private data.
https://bugzilla.redhat.com/show_bug.cgi?id=1291851
Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/qemu_domain.c | 36 ++++++++++++++++++++++++++++++++++++ src/qemu/qemu_domain.h | 9 +++++++++ 2 files changed, 45 insertions(+)
ACK

Add a new capability flag for vhost-vsock-device https://bugzilla.redhat.com/show_bug.cgi?id=1291851 Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + tests/qemucapabilitiesdata/caps_2.10.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml | 1 + 16 files changed, 17 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index bface72de2..e3d2a7825b 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -487,6 +487,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, /* 300 */ "sdl-gl", "screendump_device", + "vhost-vsock", ); @@ -1117,6 +1118,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { { "pr-manager-helper", QEMU_CAPS_PR_MANAGER_HELPER }, { "virtual-css-bridge", QEMU_CAPS_CCW }, { "vfio-ccw", QEMU_CAPS_DEVICE_VFIO_CCW }, + { "vhost-vsock-device", QEMU_CAPS_DEVICE_VHOST_VSOCK }, }; static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioBalloon[] = { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 6f9953478a..190b94bff4 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -471,6 +471,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */ /* 300 */ QEMU_CAPS_SDL_GL, /* -sdl gl */ QEMU_CAPS_SCREENDUMP_DEVICE, /* screendump command accepts device & head */ + QEMU_CAPS_DEVICE_VHOST_VSOCK, /* -device vhost-vsock-* */ QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.10.0.aarch64.xml index 5904306848..6d3b807435 100644 --- a/tests/qemucapabilitiesdata/caps_2.10.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_2.10.0.aarch64.xml @@ -155,6 +155,7 @@ <flag name='disk-write-cache'/> <flag name='nbd-tls'/> <flag name='sdl-gl'/> + <flag name='vhost-vsock'/> <version>2010000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>303541</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml index 2912c8d66b..2e876fd7f1 100644 --- a/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml @@ -154,6 +154,7 @@ <flag name='disk-write-cache'/> <flag name='nbd-tls'/> <flag name='sdl-gl'/> + <flag name='vhost-vsock'/> <version>2010000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>382824</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml index 518788ac13..e14591ed46 100644 --- a/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml @@ -116,6 +116,7 @@ <flag name='nbd-tls'/> <flag name='virtual-css-bridge'/> <flag name='sdl-gl'/> + <flag name='vhost-vsock'/> <version>2010000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>303434</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml index 77ca3013b5..32e4b6a0bf 100644 --- a/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml @@ -197,6 +197,7 @@ <flag name='disk-write-cache'/> <flag name='nbd-tls'/> <flag name='sdl-gl'/> + <flag name='vhost-vsock'/> <version>2010000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>344938</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml index 9adca9d46b..b84d03f3a7 100644 --- a/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml @@ -122,6 +122,7 @@ <flag name='pr-manager-helper'/> <flag name='virtual-css-bridge'/> <flag name='sdl-gl'/> + <flag name='vhost-vsock'/> <version>2011000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>342166</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml index de41d96cd0..b6acc58304 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml @@ -163,6 +163,7 @@ <flag name='memory-backend-file.discard-data'/> <flag name='sdl-gl'/> <flag name='screendump_device'/> + <flag name='vhost-vsock'/> <version>2011090</version> <kvmVersion>0</kvmVersion> <microcodeVersion>343099</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml index fc26f934ee..49924ff88c 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml @@ -160,6 +160,7 @@ <flag name='memory-backend-file.discard-data'/> <flag name='sdl-gl'/> <flag name='screendump_device'/> + <flag name='vhost-vsock'/> <version>2011090</version> <kvmVersion>0</kvmVersion> <microcodeVersion>419968</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml index bdfb81c998..cdffaed262 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml @@ -128,6 +128,7 @@ <flag name='vfio-ccw'/> <flag name='sdl-gl'/> <flag name='screendump_device'/> + <flag name='vhost-vsock'/> <version>2012000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>371055</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml index 820b3ef759..2b04c3d138 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml @@ -201,6 +201,7 @@ <flag name='memory-backend-file.discard-data'/> <flag name='sdl-gl'/> <flag name='screendump_device'/> + <flag name='vhost-vsock'/> <version>2011090</version> <kvmVersion>0</kvmVersion> <microcodeVersion>390813</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml index 84546b72b9..841ff01acb 100644 --- a/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml @@ -108,6 +108,7 @@ <flag name='nbd-tls'/> <flag name='virtual-css-bridge'/> <flag name='sdl-gl'/> + <flag name='vhost-vsock'/> <version>2007093</version> <kvmVersion>0</kvmVersion> <microcodeVersion>241741</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml index 7c329ad4c7..16ce016e8f 100644 --- a/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml @@ -179,6 +179,7 @@ <flag name='disk-write-cache'/> <flag name='nbd-tls'/> <flag name='sdl-gl'/> + <flag name='vhost-vsock'/> <version>2008000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>255684</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml index cfc9405095..ed2444dc8f 100644 --- a/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml @@ -146,6 +146,7 @@ <flag name='disk-write-cache'/> <flag name='nbd-tls'/> <flag name='sdl-gl'/> + <flag name='vhost-vsock'/> <version>2009000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>346538</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml index 96521efb8a..23f0e33526 100644 --- a/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml @@ -111,6 +111,7 @@ <flag name='nbd-tls'/> <flag name='virtual-css-bridge'/> <flag name='sdl-gl'/> + <flag name='vhost-vsock'/> <version>2009000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>265159</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml index 0701c244f6..e0da4d41db 100644 --- a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml @@ -192,6 +192,7 @@ <flag name='disk-write-cache'/> <flag name='nbd-tls'/> <flag name='sdl-gl'/> + <flag name='vhost-vsock'/> <version>2009000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>320947</microcodeVersion> -- 2.16.1

On Thu, May 24, 2018 at 12:39:13 +0200, Ján Tomko wrote:
Add a new capability flag for vhost-vsock-device
https://bugzilla.redhat.com/show_bug.cgi?id=1291851
Signed-off-by: Ján Tomko <jtomko@redhat.com> ---
ACK

A file for vsock-related helper functions. virVsockSetGuestCid to set an already-known CID, virVsockAcquireGuestCid that will use the first available CID https://bugzilla.redhat.com/show_bug.cgi?id=1291851 Signed-off-by: Ján Tomko <jtomko@redhat.com> --- configure.ac | 8 +++++ src/libvirt_private.syms | 5 +++ src/util/Makefile.inc.am | 2 ++ src/util/virvsock.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++ src/util/virvsock.h | 29 ++++++++++++++++ 5 files changed, 133 insertions(+) create mode 100644 src/util/virvsock.c create mode 100644 src/util/virvsock.h diff --git a/configure.ac b/configure.ac index cc005ea9e8..b869a17afe 100644 --- a/configure.ac +++ b/configure.ac @@ -641,6 +641,14 @@ if test "$with_linux" = "yes"; then [[#include <linux/devlink.h>]]) fi +dnl +dnl check for VHOST_VSOCK_SET_GUEST_CID +dnl +if test "$with_linux" = "yes"; then + AC_CHECK_DECLS([VHOST_VSOCK_SET_GUEST_CID], [], [], + [[#include <linux/vhost.h>]]) +fi + dnl Allow perl/python overrides AC_PATH_PROGS([PYTHON], [python3 python2 python]) if test -z "$PYTHON"; then diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 8e33f3e9f6..0f8045454b 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3121,6 +3121,11 @@ virVHBAManageVport; virVHBAPathExists; +# util/virvsock.h +virVsockAcquireGuestCid; +virVsockSetGuestCid; + + # util/virxml.h virXMLCheckIllegalChars; virXMLChildElementCount; diff --git a/src/util/Makefile.inc.am b/src/util/Makefile.inc.am index ec8745da7e..a22265606c 100644 --- a/src/util/Makefile.inc.am +++ b/src/util/Makefile.inc.am @@ -204,6 +204,8 @@ UTIL_SOURCES = \ util/viruuid.h \ util/virvhba.c \ util/virvhba.h \ + util/virvsock.c \ + util/virvsock.h \ util/virxdrdefs.h \ util/virxml.c \ util/virxml.h \ diff --git a/src/util/virvsock.c b/src/util/virvsock.c new file mode 100644 index 0000000000..8a5c88700b --- /dev/null +++ b/src/util/virvsock.c @@ -0,0 +1,89 @@ +/* + * 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 + * <http://www.gnu.org/licenses/>. + * + */ + +#include <config.h> + +#include <sys/ioctl.h> +/* #include <fcntl.h> */ + +#if HAVE_DECL_VHOST_VSOCK_SET_GUEST_CID +# include <linux/vhost.h> +#endif + +#include "virvsock.h" + +#include "virerror.h" +#include "virlog.h" + + +#define VIR_FROM_THIS VIR_FROM_NONE + +VIR_LOG_INIT("util.vsock"); + +#if HAVE_DECL_VHOST_VSOCK_SET_GUEST_CID +static int +virVsockSetGuestCidQuiet(int fd, + unsigned int guest_cid) +{ + uint64_t val = guest_cid; + + return ioctl(fd, VHOST_VSOCK_SET_GUEST_CID, &val); +} + +#else +static int +virVsockSetGuestCidQuiet(int fd ATTRIBUTE_UNUSED, + unsigned int guest_cid ATTRIBUTE_UNUSED) +{ + errno = ENOSYS; + return -1; +} +#endif + + +int +virVsockSetGuestCid(int fd, + unsigned int guest_cid) +{ + if (virVsockSetGuestCidQuiet(fd, guest_cid) < 0) { + virReportSystemError(errno, "%s", + _("failed to set guest cid")); + return -1; + } + + return 0; +} + +#define VIR_VSOCK_GUEST_CID_MIN 3 + +int +virVsockAcquireGuestCid(int fd, + unsigned int *guest_cid) +{ + unsigned int cid = VIR_VSOCK_GUEST_CID_MIN; + + for (; virVsockSetGuestCidQuiet(fd, cid) < 0; cid++) { + if (errno != EADDRINUSE) { + virReportSystemError(errno, "%s", + _("failed to acquire guest cid")); + return -1; + } + } + *guest_cid = cid; + + return 0; +} diff --git a/src/util/virvsock.h b/src/util/virvsock.h new file mode 100644 index 0000000000..080a322420 --- /dev/null +++ b/src/util/virvsock.h @@ -0,0 +1,29 @@ +/* + * virvsock.h - vsock related util functions + * + * 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 + * <http://www.gnu.org/licenses/>. + */ + +#ifndef __VIR_VSOCK_H__ +# define __VIR_VSOCK_H__ + +int +virVsockSetGuestCid(int fd, + unsigned int guest_cid); + +int +virVsockAcquireGuestCid(int fd, + unsigned int *guest_cid); +#endif /* __VIR_VSOCK_H__ */ -- 2.16.1

On Thu, May 24, 2018 at 12:39:14 +0200, Ján Tomko wrote:
A file for vsock-related helper functions. virVsockSetGuestCid to set an already-known CID, virVsockAcquireGuestCid that will use the first available CID
https://bugzilla.redhat.com/show_bug.cgi?id=1291851
Signed-off-by: Ján Tomko <jtomko@redhat.com> --- configure.ac | 8 +++++ src/libvirt_private.syms | 5 +++ src/util/Makefile.inc.am | 2 ++ src/util/virvsock.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++ src/util/virvsock.h | 29 ++++++++++++++++ 5 files changed, 133 insertions(+) create mode 100644 src/util/virvsock.c create mode 100644 src/util/virvsock.h
[...]
diff --git a/src/util/virvsock.c b/src/util/virvsock.c new file mode 100644 index 0000000000..8a5c88700b --- /dev/null +++ b/src/util/virvsock.c @@ -0,0 +1,89 @@ +/* + * 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 + * <http://www.gnu.org/licenses/>. + * + */ + +#include <config.h> + +#include <sys/ioctl.h> +/* #include <fcntl.h> */
Leftover historic includes?
+ +#if HAVE_DECL_VHOST_VSOCK_SET_GUEST_CID +# include <linux/vhost.h> +#endif + +#include "virvsock.h" + +#include "virerror.h" +#include "virlog.h" + + +#define VIR_FROM_THIS VIR_FROM_NONE + +VIR_LOG_INIT("util.vsock"); + +#if HAVE_DECL_VHOST_VSOCK_SET_GUEST_CID +static int +virVsockSetGuestCidQuiet(int fd, + unsigned int guest_cid) +{ + uint64_t val = guest_cid; + + return ioctl(fd, VHOST_VSOCK_SET_GUEST_CID, &val); +} + +#else +static int +virVsockSetGuestCidQuiet(int fd ATTRIBUTE_UNUSED, + unsigned int guest_cid ATTRIBUTE_UNUSED) +{ + errno = ENOSYS; + return -1; +} +#endif + + +int +virVsockSetGuestCid(int fd, + unsigned int guest_cid)
Missing docs for the internal public API.
+{ + if (virVsockSetGuestCidQuiet(fd, guest_cid) < 0) { + virReportSystemError(errno, "%s", + _("failed to set guest cid")); + return -1; + } + + return 0; +} + +#define VIR_VSOCK_GUEST_CID_MIN 3 + +int +virVsockAcquireGuestCid(int fd, + unsigned int *guest_cid)
Missing docs for the internal public API.
+{ + unsigned int cid = VIR_VSOCK_GUEST_CID_MIN; + + for (; virVsockSetGuestCidQuiet(fd, cid) < 0; cid++) {
It might be worth using an internal static atomic variable as a start of the loop so that we don't iterate cids which may still be in use.
+ if (errno != EADDRINUSE) { + virReportSystemError(errno, "%s", + _("failed to acquire guest cid")); + return -1; + } + } + *guest_cid = cid; + + return 0; +}
ACK if you add the docs and remove the commented out include.

Create a new vsock endpoint by opening /dev/vhost-vsock, set the requested CID via ioctl (or assign a free one if auto='yes'), pass the file descriptor to QEMU and build the command line. https://bugzilla.redhat.com/show_bug.cgi?id=1291851 Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/qemu_alias.c | 16 ++++++++ src/qemu/qemu_command.c | 45 ++++++++++++++++++++++ src/qemu/qemu_domain.c | 5 +++ src/qemu/qemu_domain.h | 2 +- src/qemu/qemu_process.c | 35 +++++++++++++++++ .../vhost-vsock-auto.x86_64-latest.args | 32 +++++++++++++++ .../vhost-vsock.x86_64-latest.args | 32 +++++++++++++++ tests/qemuxml2argvtest.c | 14 +++++++ 8 files changed, 180 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/vhost-vsock-auto.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/vhost-vsock.x86_64-latest.args diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index 578a33b284..89dec91ed1 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -533,6 +533,18 @@ qemuAssignDeviceInputAlias(virDomainDefPtr def, } +static int +qemuAssignDeviceVsockAlias(virDomainVsockDefPtr vsock) +{ + if (vsock->info.alias) + return 0; + if (VIR_STRDUP(vsock->info.alias, "vsock0") < 0) + return -1; + + return 0; +} + + int qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps) { @@ -629,6 +641,10 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps) if (qemuAssignDeviceMemoryAlias(NULL, def->mems[i], false) < 0) return -1; } + if (def->vsock) { + if (qemuAssignDeviceVsockAlias(def->vsock) < 0) + return -1; + } return 0; } diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 9da2d609e8..ef0716d683 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9865,6 +9865,47 @@ qemuBuildSeccompSandboxCommandLine(virCommandPtr cmd, } +static int +qemuBuildVsockCommandLine(virCommandPtr cmd, + virDomainDefPtr def, + virDomainVsockDefPtr vsock, + const char *fdprefix, + virQEMUCapsPtr qemuCaps) +{ + qemuDomainVsockPrivatePtr priv = (qemuDomainVsockPrivatePtr)vsock->privateData; + const char *device = "vhost-vsock-pci"; + virBuffer buf = VIR_BUFFER_INITIALIZER; + char *devstr = NULL; + int ret = -1; + + virBufferAsprintf(&buf, "%s", device); + virBufferAsprintf(&buf, ",id=%s", vsock->info.alias); + virBufferAsprintf(&buf, ",guest-cid=%u", vsock->guest_cid); + virBufferAsprintf(&buf, ",vhostfd=%s%u", fdprefix, priv->vhostfd); + if (qemuBuildDeviceAddressStr(&buf, def, &vsock->info, qemuCaps) < 0) + goto cleanup; +#if 0 + if (qemuBuildVirtioOptionsStr(&buf, net->virtio, qemuCaps) < 0) + goto error; +#endif + + if (virBufferCheckError(&buf) < 0) + goto cleanup; + + devstr = virBufferContentAndReset(&buf); + + virCommandPassFD(cmd, priv->vhostfd, VIR_COMMAND_PASS_FD_CLOSE_PARENT); + priv->vhostfd = -1; + virCommandAddArgList(cmd, "-device", devstr, NULL); + + ret = 0; + cleanup: + virBufferFreeAndReset(&buf); + VIR_FREE(devstr); + return ret; +} + + /* * Constructs a argv suitable for launching qemu with config defined * for a given virtual machine. @@ -10111,6 +10152,10 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, goto error; } + if (def->vsock && + qemuBuildVsockCommandLine(cmd, def, def->vsock, "", qemuCaps) < 0) + goto error; + /* In some situations, eg. VFIO passthrough, QEMU might need to lock a * significant amount of memory, so we need to set the limit accordingly */ virCommandSetMaxMemLock(cmd, qemuDomainGetMemLockLimitBytes(def)); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 527abe3b63..ff24f4b0d2 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1159,6 +1159,8 @@ qemuDomainVsockPrivateNew(void) if (!(priv = virObjectNew(qemuDomainVsockPrivateClass))) return NULL; + priv->vhostfd = -1; + return (virObjectPtr) priv; } @@ -1166,6 +1168,9 @@ qemuDomainVsockPrivateNew(void) static void qemuDomainVsockPrivateDispose(void *obj ATTRIBUTE_UNUSED) { + qemuDomainVsockPrivatePtr priv = obj; + + VIR_FORCE_CLOSE(priv->vhostfd); } diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 2046741a17..6ddf016eb7 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -446,7 +446,7 @@ typedef qemuDomainVsockPrivate *qemuDomainVsockPrivatePtr; struct _qemuDomainVsockPrivate { virObject parent; - virTristateBool maybe; + int vhostfd; }; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 174d932ae7..e318639963 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -79,6 +79,7 @@ #include "nwfilter_conf.h" #include "netdev_bandwidth_conf.h" #include "virresctrl.h" +#include "virvsock.h" #define VIR_FROM_THIS VIR_FROM_QEMU @@ -5975,6 +5976,36 @@ qemuProcessPrepareHostStorage(virQEMUDriverPtr driver, } +static int +qemuProcessOpenVhostVsock(virDomainVsockDefPtr vsock) +{ + qemuDomainVsockPrivatePtr priv = (qemuDomainVsockPrivatePtr)vsock->privateData; + const char *vsock_path = "/dev/vhost-vsock"; + int fd; + + if ((fd = open(vsock_path, O_RDWR)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + "%s", _("unable to open vhost-vsock device")); + return -1; + } + + if (vsock->guest_cid) { + if (virVsockSetGuestCid(fd, vsock->guest_cid) < 0) + goto error; + } else { + if (virVsockAcquireGuestCid(fd, &vsock->guest_cid) < 0) + goto error; + } + + priv->vhostfd = fd; + return 0; + + error: + VIR_FORCE_CLOSE(fd); + return -1; +} + + /** * qemuProcessPrepareHost: * @driver: qemu driver @@ -6000,6 +6031,10 @@ qemuProcessPrepareHost(virQEMUDriverPtr driver, if (qemuPrepareNVRAM(cfg, vm) < 0) goto cleanup; + if (vm->def->vsock) { + if (qemuProcessOpenVhostVsock(vm->def->vsock) < 0) + goto cleanup; + } /* network devices must be "prepared" before hostdevs, because * setting up a network device might create a new hostdev that * will need to be setup. diff --git a/tests/qemuxml2argvdata/vhost-vsock-auto.x86_64-latest.args b/tests/qemuxml2argvdata/vhost-vsock-auto.x86_64-latest.args new file mode 100644 index 0000000000..cefd4e3009 --- /dev/null +++ b/tests/qemuxml2argvdata/vhost-vsock-auto.x86_64-latest.args @@ -0,0 +1,32 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-x86_64 \ +-name guest=test,debug-threads=on \ +-S \ +-object secret,id=masterKey0,format=raw,\ +file=/tmp/lib/domain--1-test/master-key.aes \ +-machine pc-0.13,accel=tcg,usb=off,dump-guest-core=off \ +-m 1024 \ +-realtime mlock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid bba65c0e-c049-934f-b6aa-4e2c0582acdf \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-test/monitor.sock,\ +server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot menu=on,strict=on \ +-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ +-device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x6 \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ +resourcecontrol=deny \ +-device vhost-vsock-pci,id=vsock0,guest-cid=42,vhostfd=6789,bus=pci.0,addr=0x2 \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/vhost-vsock.x86_64-latest.args b/tests/qemuxml2argvdata/vhost-vsock.x86_64-latest.args new file mode 100644 index 0000000000..907af8bb99 --- /dev/null +++ b/tests/qemuxml2argvdata/vhost-vsock.x86_64-latest.args @@ -0,0 +1,32 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-x86_64 \ +-name guest=test,debug-threads=on \ +-S \ +-object secret,id=masterKey0,format=raw,\ +file=/tmp/lib/domain--1-test/master-key.aes \ +-machine pc-0.13,accel=tcg,usb=off,dump-guest-core=off \ +-m 1024 \ +-realtime mlock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid bba65c0e-c049-934f-b6aa-4e2c0582acdf \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-test/monitor.sock,\ +server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot menu=on,strict=on \ +-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ +-device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x6 \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ +resourcecontrol=deny \ +-device vhost-vsock-pci,id=vsock0,guest-cid=4,vhostfd=6789,bus=pci.0,addr=0x7 \ +-msg timestamp=on diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 78454acb1a..759b045e4c 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -532,6 +532,17 @@ testCompareXMLToArgv(const void *data) } } + if (vm->def->vsock) { + virDomainVsockDefPtr vsock = vm->def->vsock; + qemuDomainVsockPrivatePtr vsockPriv = + (qemuDomainVsockPrivatePtr)vsock->privateData; + + if (vsock->auto_cid == VIR_TRISTATE_BOOL_YES) + vsock->guest_cid = 42; + + vsockPriv->vhostfd = 6789; + } + if (!(cmd = qemuProcessCreatePretendCmd(&driver, vm, migrateURI, (flags & FLAG_FIPS), false, VIR_QEMU_PROCESS_START_COLD))) { @@ -2848,6 +2859,9 @@ mymain(void) QEMU_CAPS_DEVICE_VIRTIO_MOUSE_CCW, QEMU_CAPS_DEVICE_VIRTIO_TABLET_CCW); + DO_TEST_CAPS_LATEST("vhost-vsock"); + DO_TEST_CAPS_LATEST("vhost-vsock-auto"); + if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL) virFileDeleteTree(fakerootdir); -- 2.16.1

On Thu, May 24, 2018 at 12:39:15 +0200, Ján Tomko wrote:
Create a new vsock endpoint by opening /dev/vhost-vsock, set the requested CID via ioctl (or assign a free one if auto='yes'), pass the file descriptor to QEMU and build the command line.
https://bugzilla.redhat.com/show_bug.cgi?id=1291851 Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/qemu_alias.c | 16 ++++++++ src/qemu/qemu_command.c | 45 ++++++++++++++++++++++ src/qemu/qemu_domain.c | 5 +++ src/qemu/qemu_domain.h | 2 +- src/qemu/qemu_process.c | 35 +++++++++++++++++ .../vhost-vsock-auto.x86_64-latest.args | 32 +++++++++++++++ .../vhost-vsock.x86_64-latest.args | 32 +++++++++++++++ tests/qemuxml2argvtest.c | 14 +++++++ 8 files changed, 180 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/vhost-vsock-auto.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/vhost-vsock.x86_64-latest.args
[...]
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 9da2d609e8..ef0716d683 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9865,6 +9865,47 @@ qemuBuildSeccompSandboxCommandLine(virCommandPtr cmd, }
+static int +qemuBuildVsockCommandLine(virCommandPtr cmd, + virDomainDefPtr def, + virDomainVsockDefPtr vsock, + const char *fdprefix,
fdprefix is always empty string, so why is it necessary? [1]
+ virQEMUCapsPtr qemuCaps) +{ + qemuDomainVsockPrivatePtr priv = (qemuDomainVsockPrivatePtr)vsock->privateData; + const char *device = "vhost-vsock-pci"; + virBuffer buf = VIR_BUFFER_INITIALIZER; + char *devstr = NULL; + int ret = -1; + + virBufferAsprintf(&buf, "%s", device); + virBufferAsprintf(&buf, ",id=%s", vsock->info.alias); + virBufferAsprintf(&buf, ",guest-cid=%u", vsock->guest_cid); + virBufferAsprintf(&buf, ",vhostfd=%s%u", fdprefix, priv->vhostfd); + if (qemuBuildDeviceAddressStr(&buf, def, &vsock->info, qemuCaps) < 0) + goto cleanup; +#if 0 + if (qemuBuildVirtioOptionsStr(&buf, net->virtio, qemuCaps) < 0) + goto error; +#endif
Leftover stuff from previous version?
+ + if (virBufferCheckError(&buf) < 0) + goto cleanup; + + devstr = virBufferContentAndReset(&buf); + + virCommandPassFD(cmd, priv->vhostfd, VIR_COMMAND_PASS_FD_CLOSE_PARENT); + priv->vhostfd = -1; + virCommandAddArgList(cmd, "-device", devstr, NULL); + + ret = 0; + cleanup: + virBufferFreeAndReset(&buf); + VIR_FREE(devstr); + return ret; +} + + /* * Constructs a argv suitable for launching qemu with config defined * for a given virtual machine. @@ -10111,6 +10152,10 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, goto error; }
+ if (def->vsock && + qemuBuildVsockCommandLine(cmd, def, def->vsock, "", qemuCaps) < 0)
[1]
+ goto error; + /* In some situations, eg. VFIO passthrough, QEMU might need to lock a * significant amount of memory, so we need to set the limit accordingly */ virCommandSetMaxMemLock(cmd, qemuDomainGetMemLockLimitBytes(def));
[...]
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 174d932ae7..e318639963 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c
[...]
@@ -5975,6 +5976,36 @@ qemuProcessPrepareHostStorage(virQEMUDriverPtr driver, }
+static int +qemuProcessOpenVhostVsock(virDomainVsockDefPtr vsock) +{ + qemuDomainVsockPrivatePtr priv = (qemuDomainVsockPrivatePtr)vsock->privateData; + const char *vsock_path = "/dev/vhost-vsock"; + int fd; + + if ((fd = open(vsock_path, O_RDWR)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + "%s", _("unable to open vhost-vsock device")); + return -1; + } + + if (vsock->guest_cid) { + if (virVsockSetGuestCid(fd, vsock->guest_cid) < 0) + goto error; + } else { + if (virVsockAcquireGuestCid(fd, &vsock->guest_cid) < 0) + goto error;
This logic is wrong. You should base the decision on auto_cid, rather than presence of guest_cid. If automatic cid is requested you should always honour it. Specifically this might create problem with migration as the cid that was used on the source was already taken, but the user is okay with autogenerating it. Or if the cid actually can't change, you should make it part of the ABI stability check.
+ } + + priv->vhostfd = fd; + return 0; +

On Tue, May 29, 2018 at 11:16:40AM +0200, Peter Krempa wrote:
On Thu, May 24, 2018 at 12:39:15 +0200, Ján Tomko wrote:
Create a new vsock endpoint by opening /dev/vhost-vsock, set the requested CID via ioctl (or assign a free one if auto='yes'), pass the file descriptor to QEMU and build the command line.
https://bugzilla.redhat.com/show_bug.cgi?id=1291851 Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/qemu_alias.c | 16 ++++++++ src/qemu/qemu_command.c | 45 ++++++++++++++++++++++ src/qemu/qemu_domain.c | 5 +++ src/qemu/qemu_domain.h | 2 +- src/qemu/qemu_process.c | 35 +++++++++++++++++ .../vhost-vsock-auto.x86_64-latest.args | 32 +++++++++++++++ .../vhost-vsock.x86_64-latest.args | 32 +++++++++++++++ tests/qemuxml2argvtest.c | 14 +++++++ 8 files changed, 180 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/vhost-vsock-auto.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/vhost-vsock.x86_64-latest.args
[...]
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 9da2d609e8..ef0716d683 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9865,6 +9865,47 @@ qemuBuildSeccompSandboxCommandLine(virCommandPtr cmd, }
+static int +qemuBuildVsockCommandLine(virCommandPtr cmd, + virDomainDefPtr def, + virDomainVsockDefPtr vsock, + const char *fdprefix,
fdprefix is always empty string, so why is it necessary?
[1]
It will be necessary for hotplug, because AFAIK the name of the file descriptor passed via monitor cannot start with a digit. It has no place in this patch.
+ virQEMUCapsPtr qemuCaps) +{ + qemuDomainVsockPrivatePtr priv = (qemuDomainVsockPrivatePtr)vsock->privateData; + const char *device = "vhost-vsock-pci"; + virBuffer buf = VIR_BUFFER_INITIALIZER; + char *devstr = NULL; + int ret = -1; + + virBufferAsprintf(&buf, "%s", device); + virBufferAsprintf(&buf, ",id=%s", vsock->info.alias); + virBufferAsprintf(&buf, ",guest-cid=%u", vsock->guest_cid); + virBufferAsprintf(&buf, ",vhostfd=%s%u", fdprefix, priv->vhostfd); + if (qemuBuildDeviceAddressStr(&buf, def, &vsock->info, qemuCaps) < 0) + goto cleanup; +#if 0 + if (qemuBuildVirtioOptionsStr(&buf, net->virtio, qemuCaps) < 0) + goto error; +#endif
Leftover stuff from previous version?
While ats= is not that useful for every device, I'm afraid iommu_platform might be and a followup implementing it will be required.
+ + if (virBufferCheckError(&buf) < 0) + goto cleanup; + + devstr = virBufferContentAndReset(&buf); + + virCommandPassFD(cmd, priv->vhostfd, VIR_COMMAND_PASS_FD_CLOSE_PARENT); + priv->vhostfd = -1; + virCommandAddArgList(cmd, "-device", devstr, NULL); + + ret = 0; + cleanup: + virBufferFreeAndReset(&buf); + VIR_FREE(devstr); + return ret; +} + + /* * Constructs a argv suitable for launching qemu with config defined * for a given virtual machine. @@ -10111,6 +10152,10 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, goto error; }
+ if (def->vsock && + qemuBuildVsockCommandLine(cmd, def, def->vsock, "", qemuCaps) < 0)
[1]
+ goto error; + /* In some situations, eg. VFIO passthrough, QEMU might need to lock a * significant amount of memory, so we need to set the limit accordingly */ virCommandSetMaxMemLock(cmd, qemuDomainGetMemLockLimitBytes(def));
[...]
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 174d932ae7..e318639963 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c
[...]
@@ -5975,6 +5976,36 @@ qemuProcessPrepareHostStorage(virQEMUDriverPtr driver, }
+static int +qemuProcessOpenVhostVsock(virDomainVsockDefPtr vsock) +{ + qemuDomainVsockPrivatePtr priv = (qemuDomainVsockPrivatePtr)vsock->privateData; + const char *vsock_path = "/dev/vhost-vsock"; + int fd; + + if ((fd = open(vsock_path, O_RDWR)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + "%s", _("unable to open vhost-vsock device")); + return -1; + } + + if (vsock->guest_cid) { + if (virVsockSetGuestCid(fd, vsock->guest_cid) < 0) + goto error; + } else { + if (virVsockAcquireGuestCid(fd, &vsock->guest_cid) < 0) + goto error;
This logic is wrong. You should base the decision on auto_cid, rather than presence of guest_cid. If automatic cid is requested you should always honour it.
Specifically this might create problem with migration as the cid that was used on the source was already taken, but the user is okay with autogenerating it.
Or if the cid actually can't change, you should make it part of the ABI stability check.
I don't think migrating the device would make sense if you would not be able to change the CIDs. Jano

On Thu, May 24, 2018 at 12:39:08PM +0200, Ján Tomko wrote:
v1: https://www.redhat.com/archives/libvir-list/2018-May/msg01517.html v2: * use <vsock> instead of <interface> * use <source> for the guest address * add <source auto> attribute and auto-assign the guest CID * fixed PCI address allocation https://bugzilla.redhat.com/show_bug.cgi?id=1291851
Ján Tomko (7): Introduce virDomainVsockDef Add privateData to virDomainVsockDef conf: introduce <vsock> element qemu: add private data for vsock Introduce QEMU_CAPS_DEVICE_VHOST_VSOCK util: create virvsock.c qemu: add support for vhost-vsock-pci
I forgot to rebase on the latest capability changes, if you do not want to resolve them yourselves [0] they are also on my repo.cz: git://repo.or.cz/libvirt/jtomko.git vsock-v2 http://repo.or.cz/libvirt/jtomko.git/shortlog/refs/heads/vsock-v2 Jano [0] or with my naive merge tool https://www.redhat.com/archives/libvir-list/2018-April/msg00942.html

Create a new vsock endpoint by opening /dev/vhost-vsock, set the requested CID via ioctl (or assign a free one if auto='yes'), pass the file descriptor to QEMU and build the command line. https://bugzilla.redhat.com/show_bug.cgi?id=1291851 Signed-off-by: Ján Tomko <jtomko@redhat.com> --- Rebased version with all the ACKed squash-ins for patches 1-6 available at: git://repo.or.cz/libvirt/jtomko.git vsock-v3 http://repo.or.cz/libvirt/jtomko.git/shortlog/refs/heads/vsock-v3 src/qemu/qemu_alias.c | 16 +++++++++ src/qemu/qemu_command.c | 40 ++++++++++++++++++++++ src/qemu/qemu_domain.c | 5 +++ src/qemu/qemu_domain.h | 2 +- src/qemu/qemu_process.c | 35 +++++++++++++++++++ .../vhost-vsock-auto.x86_64-latest.args | 32 +++++++++++++++++ .../vhost-vsock.x86_64-latest.args | 32 +++++++++++++++++ tests/qemuxml2argvtest.c | 14 ++++++++ 8 files changed, 175 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/vhost-vsock-auto.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/vhost-vsock.x86_64-latest.args diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index 578a33b284..89dec91ed1 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -533,6 +533,18 @@ qemuAssignDeviceInputAlias(virDomainDefPtr def, } +static int +qemuAssignDeviceVsockAlias(virDomainVsockDefPtr vsock) +{ + if (vsock->info.alias) + return 0; + if (VIR_STRDUP(vsock->info.alias, "vsock0") < 0) + return -1; + + return 0; +} + + int qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps) { @@ -629,6 +641,10 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps) if (qemuAssignDeviceMemoryAlias(NULL, def->mems[i], false) < 0) return -1; } + if (def->vsock) { + if (qemuAssignDeviceVsockAlias(def->vsock) < 0) + return -1; + } return 0; } diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index c7ff074e29..0b5ec4f2ba 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9912,6 +9912,42 @@ qemuBuildSeccompSandboxCommandLine(virCommandPtr cmd, } +static int +qemuBuildVsockCommandLine(virCommandPtr cmd, + virDomainDefPtr def, + virDomainVsockDefPtr vsock, + virQEMUCapsPtr qemuCaps) +{ + qemuDomainVsockPrivatePtr priv = (qemuDomainVsockPrivatePtr)vsock->privateData; + const char *device = "vhost-vsock-pci"; + virBuffer buf = VIR_BUFFER_INITIALIZER; + char *devstr = NULL; + int ret = -1; + + virBufferAsprintf(&buf, "%s", device); + virBufferAsprintf(&buf, ",id=%s", vsock->info.alias); + virBufferAsprintf(&buf, ",guest-cid=%u", vsock->guest_cid); + virBufferAsprintf(&buf, ",vhostfd=%u", priv->vhostfd); + if (qemuBuildDeviceAddressStr(&buf, def, &vsock->info, qemuCaps) < 0) + goto cleanup; + + if (virBufferCheckError(&buf) < 0) + goto cleanup; + + devstr = virBufferContentAndReset(&buf); + + virCommandPassFD(cmd, priv->vhostfd, VIR_COMMAND_PASS_FD_CLOSE_PARENT); + priv->vhostfd = -1; + virCommandAddArgList(cmd, "-device", devstr, NULL); + + ret = 0; + cleanup: + virBufferFreeAndReset(&buf); + VIR_FREE(devstr); + return ret; +} + + /* * Constructs a argv suitable for launching qemu with config defined * for a given virtual machine. @@ -10161,6 +10197,10 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, goto error; } + if (def->vsock && + qemuBuildVsockCommandLine(cmd, def, def->vsock, qemuCaps) < 0) + goto error; + /* In some situations, eg. VFIO passthrough, QEMU might need to lock a * significant amount of memory, so we need to set the limit accordingly */ virCommandSetMaxMemLock(cmd, qemuDomainGetMemLockLimitBytes(def)); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 10f22b1cc2..2c51e4c0d8 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1160,6 +1160,8 @@ qemuDomainVsockPrivateNew(void) if (!(priv = virObjectNew(qemuDomainVsockPrivateClass))) return NULL; + priv->vhostfd = -1; + return (virObjectPtr) priv; } @@ -1167,6 +1169,9 @@ qemuDomainVsockPrivateNew(void) static void qemuDomainVsockPrivateDispose(void *obj ATTRIBUTE_UNUSED) { + qemuDomainVsockPrivatePtr priv = obj; + + VIR_FORCE_CLOSE(priv->vhostfd); } diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index f298ebf785..2e0f4df0fb 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -447,7 +447,7 @@ typedef qemuDomainVsockPrivate *qemuDomainVsockPrivatePtr; struct _qemuDomainVsockPrivate { virObject parent; - virTristateBool maybe; + int vhostfd; }; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 5f5759c9c8..30cc5904e0 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -79,6 +79,7 @@ #include "nwfilter_conf.h" #include "netdev_bandwidth_conf.h" #include "virresctrl.h" +#include "virvsock.h" #define VIR_FROM_THIS VIR_FROM_QEMU @@ -5947,6 +5948,36 @@ qemuProcessPrepareHostStorage(virQEMUDriverPtr driver, } +static int +qemuProcessOpenVhostVsock(virDomainVsockDefPtr vsock) +{ + qemuDomainVsockPrivatePtr priv = (qemuDomainVsockPrivatePtr)vsock->privateData; + const char *vsock_path = "/dev/vhost-vsock"; + int fd; + + if ((fd = open(vsock_path, O_RDWR)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + "%s", _("unable to open vhost-vsock device")); + return -1; + } + + if (vsock->auto_cid == VIR_TRISTATE_BOOL_YES) { + if (virVsockAcquireGuestCid(fd, &vsock->guest_cid) < 0) + goto error; + } else { + if (virVsockSetGuestCid(fd, vsock->guest_cid) < 0) + goto error; + } + + priv->vhostfd = fd; + return 0; + + error: + VIR_FORCE_CLOSE(fd); + return -1; +} + + /** * qemuProcessPrepareHost: * @driver: qemu driver @@ -5972,6 +6003,10 @@ qemuProcessPrepareHost(virQEMUDriverPtr driver, if (qemuPrepareNVRAM(cfg, vm) < 0) goto cleanup; + if (vm->def->vsock) { + if (qemuProcessOpenVhostVsock(vm->def->vsock) < 0) + goto cleanup; + } /* network devices must be "prepared" before hostdevs, because * setting up a network device might create a new hostdev that * will need to be setup. diff --git a/tests/qemuxml2argvdata/vhost-vsock-auto.x86_64-latest.args b/tests/qemuxml2argvdata/vhost-vsock-auto.x86_64-latest.args new file mode 100644 index 0000000000..dd9b60ba3e --- /dev/null +++ b/tests/qemuxml2argvdata/vhost-vsock-auto.x86_64-latest.args @@ -0,0 +1,32 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-x86_64 \ +-name guest=test,debug-threads=on \ +-S \ +-object secret,id=masterKey0,format=raw,\ +file=/tmp/lib/domain--1-test/master-key.aes \ +-machine pc-i440fx-2.9,accel=tcg,usb=off,dump-guest-core=off \ +-m 1024 \ +-realtime mlock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid bba65c0e-c049-934f-b6aa-4e2c0582acdf \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-test/monitor.sock,\ +server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot menu=on,strict=on \ +-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ +-device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x6 \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ +resourcecontrol=deny \ +-device vhost-vsock-pci,id=vsock0,guest-cid=42,vhostfd=6789,bus=pci.0,addr=0x2 \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/vhost-vsock.x86_64-latest.args b/tests/qemuxml2argvdata/vhost-vsock.x86_64-latest.args new file mode 100644 index 0000000000..907af8bb99 --- /dev/null +++ b/tests/qemuxml2argvdata/vhost-vsock.x86_64-latest.args @@ -0,0 +1,32 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-x86_64 \ +-name guest=test,debug-threads=on \ +-S \ +-object secret,id=masterKey0,format=raw,\ +file=/tmp/lib/domain--1-test/master-key.aes \ +-machine pc-0.13,accel=tcg,usb=off,dump-guest-core=off \ +-m 1024 \ +-realtime mlock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid bba65c0e-c049-934f-b6aa-4e2c0582acdf \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-test/monitor.sock,\ +server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot menu=on,strict=on \ +-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ +-device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x6 \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ +resourcecontrol=deny \ +-device vhost-vsock-pci,id=vsock0,guest-cid=4,vhostfd=6789,bus=pci.0,addr=0x7 \ +-msg timestamp=on diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 2fe4390104..ddd2b88c0a 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -532,6 +532,17 @@ testCompareXMLToArgv(const void *data) } } + if (vm->def->vsock) { + virDomainVsockDefPtr vsock = vm->def->vsock; + qemuDomainVsockPrivatePtr vsockPriv = + (qemuDomainVsockPrivatePtr)vsock->privateData; + + if (vsock->auto_cid == VIR_TRISTATE_BOOL_YES) + vsock->guest_cid = 42; + + vsockPriv->vhostfd = 6789; + } + if (!(cmd = qemuProcessCreatePretendCmd(&driver, vm, migrateURI, (flags & FLAG_FIPS), false, VIR_QEMU_PROCESS_START_COLD))) { @@ -2856,6 +2867,9 @@ mymain(void) QEMU_CAPS_DEVICE_VIRTIO_MOUSE_CCW, QEMU_CAPS_DEVICE_VIRTIO_TABLET_CCW); + DO_TEST_CAPS_LATEST("vhost-vsock"); + DO_TEST_CAPS_LATEST("vhost-vsock-auto"); + if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL) virFileDeleteTree(fakerootdir); -- 2.16.1

On Tue, May 29, 2018 at 14:53:14 +0200, Ján Tomko wrote:
Create a new vsock endpoint by opening /dev/vhost-vsock, set the requested CID via ioctl (or assign a free one if auto='yes'), pass the file descriptor to QEMU and build the command line.
https://bugzilla.redhat.com/show_bug.cgi?id=1291851 Signed-off-by: Ján Tomko <jtomko@redhat.com> --- Rebased version with all the ACKed squash-ins for patches 1-6 available at: git://repo.or.cz/libvirt/jtomko.git vsock-v3 http://repo.or.cz/libvirt/jtomko.git/shortlog/refs/heads/vsock-v3
Note that the linked branch is not in pushable state. Patch 3 does not have a sign-off and the 'squash-in' patch was not actually squashed in. In patch " util: create virvsock.c" there's a copy-paste error in the docs for virVsockAcquireGuestCid, where it also mentions what virVsockSetGuestCid does. Once you'll be editing that commit, please add the colons after function names too. ACK series with the two points above addressed.
participants (3)
-
Daniel P. Berrangé
-
Ján Tomko
-
Peter Krempa