[libvirt] [PATCH] qemu: Add default address type for vhost-user interface on aarch64

Wang Yechao posted 1 patch 5 years, 3 months ago
Test syntax-check passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/1544779172-5512-1-git-send-email-wang.yechao255@zte.com.cn
src/qemu/qemu_hotplug.c | 5 +++++
1 file changed, 5 insertions(+)
[libvirt] [PATCH] qemu: Add default address type for vhost-user interface on aarch64
Posted by Wang Yechao 5 years, 3 months ago
on aarch64, hotadd vhost-user interface with the follow xml file:
<interface type='vhostuser'>
  <mac address='fa:16:3e:a2:e1:58'/>
  <source type='unix' path='/var/run/vhu24a3f044-80' mode='server'/>
  <target dev='vhu24a3f044-80'/>
  <model type='virtio'/>
</interface>

will get error like that:
error: internal error: Nicdev support unavailable

Because there is no device address type specified in xml file, so
qemuDomainSupportsNicdev returns 'false' when invoked in
qemuDomainAttachNetDevice. Using pci as the default address type,
and assigns pci address later in qemuDomainEnsurePCIAddress.

Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>
---
 src/qemu/qemu_hotplug.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 68d021a..c1464a9 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1443,6 +1443,11 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
         queueSize = net->driver.virtio.queues;
         if (!queueSize)
             queueSize = 1;
+
+        if (!net->info.type &&
+            vm->def->os.arch == VIR_ARCH_AARCH64)
+            net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
+
         if (!qemuDomainSupportsNicdev(vm->def, net)) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            "%s", _("Nicdev support unavailable"));
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: Add default address type for vhost-user interface on aarch64
Posted by Michal Privoznik 5 years, 3 months ago
On 12/14/18 10:19 AM, Wang Yechao wrote:
> on aarch64, hotadd vhost-user interface with the follow xml file:
> <interface type='vhostuser'>
>   <mac address='fa:16:3e:a2:e1:58'/>
>   <source type='unix' path='/var/run/vhu24a3f044-80' mode='server'/>
>   <target dev='vhu24a3f044-80'/>
>   <model type='virtio'/>
> </interface>
> 
> will get error like that:
> error: internal error: Nicdev support unavailable
> 
> Because there is no device address type specified in xml file, so
> qemuDomainSupportsNicdev returns 'false' when invoked in
> qemuDomainAttachNetDevice. Using pci as the default address type,
> and assigns pci address later in qemuDomainEnsurePCIAddress.
> 
> Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>
> ---
>  src/qemu/qemu_hotplug.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
> index 68d021a..c1464a9 100644
> --- a/src/qemu/qemu_hotplug.c
> +++ b/src/qemu/qemu_hotplug.c
> @@ -1443,6 +1443,11 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
>          queueSize = net->driver.virtio.queues;
>          if (!queueSize)
>              queueSize = 1;
> +
> +        if (!net->info.type &&
> +            vm->def->os.arch == VIR_ARCH_AARCH64)
> +            net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;

This is almost certainly incorrect. At this point, the address should
have been already assigned. Maybe you need to look into why it wasn't.

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt][PATCH] qemu: Add default address type for vhost-userinterface on aarch64
Posted by wang.yechao255@zte.com.cn 5 years, 3 months ago
> On 12/14/18 10:19 AM, Wang Yechao wrote:
> > on aarch64, hotadd vhost-user interface with the follow xml file:
> > <interface type='vhostuser'>
> >   <mac address='fa:16:3e:a2:e1:58'/>
> >   <source type='unix' path='/var/run/vhu24a3f044-80' mode='server'/>
> >   <target dev='vhu24a3f044-80'/>
> >   <model type='virtio'/>
> > </interface>
> >
> > will get error like that:
> > error: internal error: Nicdev support unavailable
> >
> > Because there is no device address type specified in xml file, so
> > qemuDomainSupportsNicdev returns 'false' when invoked in
> > qemuDomainAttachNetDevice. Using pci as the default address type,
> > and assigns pci address later in qemuDomainEnsurePCIAddress.
> >
> > Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>
> > ---
> >  src/qemu/qemu_hotplug.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
> > index 68d021a..c1464a9 100644
> > --- a/src/qemu/qemu_hotplug.c
> > +++ b/src/qemu/qemu_hotplug.c
> > @@ -1443,6 +1443,11 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
> >          queueSize = net->driver.virtio.queues;
> >          if (!queueSize)
> >              queueSize = 1;
> > +
> > +        if (!net->info.type &&
> > +            vm->def->os.arch == VIR_ARCH_AARCH64)
> > +            net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
>
> This is almost certainly incorrect. At this point, the address should
> have been already assigned. Maybe you need to look into why it wasn't.
>
> Michal

Thank you for your immediate reply. I have checked the 'vhostuser' type
and 'bridge' type interface on x86, 'bridge' type interface on aarch64:
hotadd these devices with no address specified in xml file, the address
has also not been assigned at this point, but it works well. All of that
assign an address in qemuDomainEnsurePCIAddress in the later time.
Can I put the qemuDomainEnsurePCIAddress before the switch statement?
such as:

--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1369,6 +1369,25 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
     if (qemuAssignDeviceNetAlias(vm->def, net, -1) < 0)
         goto cleanup;

+    if (qemuDomainIsS390CCW(vm->def) &&
+        net->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI &&
+        virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_CCW)) {
+        net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW;
+        if (!(ccwaddrs = virDomainCCWAddressSetCreateFromDomain(vm->def)))
+            goto cleanup;
+        if (virDomainCCWAddressAssign(&net->info, ccwaddrs,
+                                      !net->info.addr.ccw.assigned) < 0)
+            goto cleanup;
+    } else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390)) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("virtio-s390 net device cannot be hotplugged."));
+        goto cleanup;
+    } else if (qemuDomainEnsurePCIAddress(vm, &dev, driver) < 0) {
+        goto cleanup;
+    }
+
+    releaseaddr = true;
+
     switch (actualType) {
     case VIR_DOMAIN_NET_TYPE_BRIDGE:
     case VIR_DOMAIN_NET_TYPE_NETWORK:
@@ -1503,25 +1522,6 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
             goto cleanup;
     }

-    if (qemuDomainIsS390CCW(vm->def) &&
-        net->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI &&
-        virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_CCW)) {
-        net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW;
-        if (!(ccwaddrs = virDomainCCWAddressSetCreateFromDomain(vm->def)))
-            goto cleanup;
-        if (virDomainCCWAddressAssign(&net->info, ccwaddrs,
-                                      !net->info.addr.ccw.assigned) < 0)
-            goto cleanup;
-    } else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390)) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("virtio-s390 net device cannot be hotplugged."));
-        goto cleanup;
-    } else if (qemuDomainEnsurePCIAddress(vm, &dev, driver) < 0) {
-        goto cleanup;
-    }
-
-    releaseaddr = true;
-
     if (VIR_ALLOC_N(tapfdName, tapfdSize) < 0 ||


---
Best wishes
Wang Yechao--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: Add default address type for vhost-userinterface on aarch64
Posted by Michal Privoznik 5 years, 3 months ago
On 12/17/18 9:30 AM, wang.yechao255@zte.com.cn wrote:
>> On 12/14/18 10:19 AM, Wang Yechao wrote:
>>> on aarch64, hotadd vhost-user interface with the follow xml file:
>>> <interface type='vhostuser'>
>>>   <mac address='fa:16:3e:a2:e1:58'/>
>>>   <source type='unix' path='/var/run/vhu24a3f044-80' mode='server'/>
>>>   <target dev='vhu24a3f044-80'/>
>>>   <model type='virtio'/>
>>> </interface>
>>>
>>> will get error like that:
>>> error: internal error: Nicdev support unavailable
>>>
>>> Because there is no device address type specified in xml file, so
>>> qemuDomainSupportsNicdev returns 'false' when invoked in
>>> qemuDomainAttachNetDevice. Using pci as the default address type,
>>> and assigns pci address later in qemuDomainEnsurePCIAddress.
>>>
>>> Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>
>>> ---
>>>  src/qemu/qemu_hotplug.c | 5 +++++
>>>  1 file changed, 5 insertions(+)
>>>
>>> diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
>>> index 68d021a..c1464a9 100644
>>> --- a/src/qemu/qemu_hotplug.c
>>> +++ b/src/qemu/qemu_hotplug.c
>>> @@ -1443,6 +1443,11 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
>>>          queueSize = net->driver.virtio.queues;
>>>          if (!queueSize)
>>>              queueSize = 1;
>>> +
>>> +        if (!net->info.type &&
>>> +            vm->def->os.arch == VIR_ARCH_AARCH64)
>>> +            net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
>>
>> This is almost certainly incorrect. At this point, the address should
>> have been already assigned. Maybe you need to look into why it wasn't.
>>
>> Michal
> 
> Thank you for your immediate reply. I have checked the 'vhostuser' type
> and 'bridge' type interface on x86, 'bridge' type interface on aarch64:
> hotadd these devices with no address specified in xml file, the address
> has also not been assigned at this point, but it works well. All of that
> assign an address in qemuDomainEnsurePCIAddress in the later time.
> Can I put the qemuDomainEnsurePCIAddress before the switch statement?
> such as:
> 
> --- a/src/qemu/qemu_hotplug.c
> +++ b/src/qemu/qemu_hotplug.c
> @@ -1369,6 +1369,25 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
>      if (qemuAssignDeviceNetAlias(vm->def, net, -1) < 0)
>          goto cleanup;
> 
> +    if (qemuDomainIsS390CCW(vm->def) &&
> +        net->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI &&
> +        virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_CCW)) {
> +        net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW;
> +        if (!(ccwaddrs = virDomainCCWAddressSetCreateFromDomain(vm->def)))
> +            goto cleanup;
> +        if (virDomainCCWAddressAssign(&net->info, ccwaddrs,
> +                                      !net->info.addr.ccw.assigned) < 0)
> +            goto cleanup;
> +    } else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390)) {
> +        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> +                       _("virtio-s390 net device cannot be hotplugged."));
> +        goto cleanup;
> +    } else if (qemuDomainEnsurePCIAddress(vm, &dev, driver) < 0) {
> +        goto cleanup;
> +    }
> +
> +    releaseaddr = true;
> +
>      switch (actualType) {
>      case VIR_DOMAIN_NET_TYPE_BRIDGE:
>      case VIR_DOMAIN_NET_TYPE_NETWORK:
> @@ -1503,25 +1522,6 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
>              goto cleanup;
>      }
> 
> -    if (qemuDomainIsS390CCW(vm->def) &&
> -        net->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI &&
> -        virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_CCW)) {
> -        net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW;
> -        if (!(ccwaddrs = virDomainCCWAddressSetCreateFromDomain(vm->def)))
> -            goto cleanup;
> -        if (virDomainCCWAddressAssign(&net->info, ccwaddrs,
> -                                      !net->info.addr.ccw.assigned) < 0)
> -            goto cleanup;
> -    } else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390)) {
> -        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> -                       _("virtio-s390 net device cannot be hotplugged."));
> -        goto cleanup;
> -    } else if (qemuDomainEnsurePCIAddress(vm, &dev, driver) < 0) {
> -        goto cleanup;
> -    }
> -
> -    releaseaddr = true;
> -
>      if (VIR_ALLOC_N(tapfdName, tapfdSize) < 0 ||
> 
> 

Yes, this looks reasonable. Can you send it as a patch please?

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list