[libvirt] [PATCHv3 1/2] qemu: support vhost in attach-interface

Eric Blake eblake at redhat.com
Thu Mar 10 15:31:46 UTC 2011


On 03/09/2011 09:54 PM, Laine Stump wrote:
> On 03/09/2011 03:42 PM, Eric Blake wrote:
>> * src/qemu/qemu_hotplug.c (qemuDomainAttachNetDevice): Honor vhost
>> designations, similar to qemu_command code paths.
>> * src/qemu/qemu_command.h (qemuOpenVhostNet): New prototype.
>> * src/qemu/qemu_command.c (qemuOpenVhostNet): Export.
>> ---

>> +    if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK ||
>> +        net->type == VIR_DOMAIN_NET_TYPE_BRIDGE ||
>> +        net->type == VIR_DOMAIN_NET_TYPE_DIRECT) {
>> +        /* Attempt to use vhost-net mode for these types of
>> +           network device */
>> +        if (qemuOpenVhostNet(net, qemuCaps,&vhostfd)<  0)
>> +            goto cleanup;
>> +
>> +        if (vhostfd>= 0&&
>> +            priv->monConfig->type != VIR_DOMAIN_CHR_TYPE_UNIX) {
>> +            qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
>> +                            _("network device type '%s' cannot be
>> attached: "
>> +                            "qemu is not using a unix socket monitor"),
>> +                            virDomainNetTypeToString(net->type));
>> +            goto cleanup;
>> +        }
> 
> 
> The above check has already been handled by a combination of the checks
> in the if { } else if { } block above, so it's superfluous here.
> 
> ACK with this extra check for monConfig-type removed.

Indeed.  I simplified as follows, then pushed.

diff --git c/src/qemu/qemu_hotplug.c i/src/qemu/qemu_hotplug.c
index e8567ad..540939a 100644
--- c/src/qemu/qemu_hotplug.c
+++ i/src/qemu/qemu_hotplug.c
@@ -578,6 +578,8 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,

         if ((tapfd = qemuNetworkIfaceConnect(conn, driver, net,
qemuCaps)) < 0)
             return -1;
+        if (qemuOpenVhostNet(net, qemuCaps, &vhostfd) < 0)
+            goto cleanup;
     } else if (net->type == VIR_DOMAIN_NET_TYPE_DIRECT) {
         if (priv->monConfig->type != VIR_DOMAIN_CHR_TYPE_UNIX) {
             qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
@@ -592,24 +594,8 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
                                           vm->def->uuid,
                                           VIR_VM_OP_CREATE)) < 0)
             return -1;
-    }
-
-    if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK ||
-        net->type == VIR_DOMAIN_NET_TYPE_BRIDGE ||
-        net->type == VIR_DOMAIN_NET_TYPE_DIRECT) {
-        /* Attempt to use vhost-net mode for these types of
-           network device */
         if (qemuOpenVhostNet(net, qemuCaps, &vhostfd) < 0)
             goto cleanup;
-
-        if (vhostfd >= 0 &&
-            priv->monConfig->type != VIR_DOMAIN_CHR_TYPE_UNIX) {
-            qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                            _("network device type '%s' cannot be
attached: "
-                            "qemu is not using a unix socket monitor"),
-                            virDomainNetTypeToString(net->type));
-            goto cleanup;
-        }
     }

     if (VIR_REALLOC_N(vm->def->nets, vm->def->nnets+1) < 0)

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110310/c344e183/attachment-0001.sig>


More information about the libvir-list mailing list