[libvirt] [PATCH ] (type ioem) adding qemu nic configuration option in to libvirt (XEN)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Guys

I have added a new attribute with with in <interface > tag called "qemu" which can be either true or false..

Indicating if the user wants XEN to create qeum net device or not.. This will fix the problem with PV net drivers with XEN..

Check the following examples
e.g 1) Interface tag with qemu attribute set to false

<interface type='bridge' qemu='false'>
     <mac address='00:16:3e:00:a5:01'/>
     <source bridge='eth0'/>
     <target dev='vif1.0'/>
</interface>

qemu-dm output
---------------------
/usr/lib64/xen/bin/qemu-dm -d 60 -domain-name benchmark1 -k en-gb -vnc 0.0.0.0:1 -vcpus 2 -boot c -serial pty -acpi -usb -net none -M xenfv

XEND has configured the hvm guest not to have network card via qemu

e.g 2) Interface tag with qemu attribute set to true with qemu supported nic model

<interface type='bridge' qemu='true'>
     <mac address='00:16:3e:00:a5:01'/>
     <source bridge='eth0'/>
     <target dev='vif1.0'/>
     <model type='e1000'/>
   </interface>

qemu-dm output
---------------------
/usr/lib64/xen/bin/qemu-dm -d 61 -domain-name benchmark1 -k en-gb -vnc 0.0.0.0:1 -vcpus 2 -boot c -serial pty -acpi -usb -net nic,vlan=1,macaddr=00:16:3e:00:a5:01,model=e1000 -net tap,vlan=1,ifname=tap61.0,bridge=eth0 -M xenfv

Now XEND have configured the hvm guest to have emulated nic of the model "e1000"

Therefore now, via libvirt configuration I have the ability ask xen to either to configure qemu network card or not (when I have pv divers installed with in my VM )


I have attached the patch files, Let me know what you guys think.

Thanks
Gihan

--
Gihan Munasinghe
R&D Team Leader
XCalibre Communications Ltd.
www.flexiscale.com

--- domain_conf.h.back	2008-12-04 15:31:38.000000000 +0000
+++ domain_conf.h	2008-12-04 20:28:16.000000000 +0000
@@ -127,9 +127,17 @@
     VIR_DOMAIN_NET_TYPE_NETWORK,
     VIR_DOMAIN_NET_TYPE_BRIDGE,
 
-    VIR_DOMAIN_NET_TYPE_LAST,
+    VIR_DOMAIN_NET_TYPE_LAST
 };
 
+/*Holds the values that can be passed as qemu attribute in <inteface >*/
+enum virDomainNetQemuAllocateType{
+     VIR_DOMAIN_NET_QEMU_ALLOC_TRUE,
+     VIR_DOMAIN_NET_QEMU_ALLOC_FALSE,
+
+     VIR_DOMAIN_NET_QEMU_ALLOC_LAST
+    
+};
 
 /* Stores the virtual network interface configuration */
 typedef struct _virDomainNetDef virDomainNetDef;
@@ -156,6 +164,8 @@
         } bridge;
     } data;
     char *ifname;
+    int qemu_allocate;/* This is set so that the users can ask xen not give vm's a network card
+		       maily to with the (type none)/(type ieoum) tags wchi will be send to xend*/
 };
 
 enum virDomainChrSrcType {
@@ -608,5 +618,5 @@
 VIR_ENUM_DECL(virDomainInput)
 VIR_ENUM_DECL(virDomainInputBus)
 VIR_ENUM_DECL(virDomainGraphics)
-
+VIR_ENUM_DECL(virDomainNetQemuAllocate)
 #endif /* __DOMAIN_CONF_H */
--- domain_conf.c.back	2008-12-04 15:31:40.000000000 +0000
+++ domain_conf.c	2008-12-04 20:30:31.000000000 +0000
@@ -142,6 +142,10 @@
               "usb",
               "pci")
 
+VIR_ENUM_IMPL(virDomainNetQemuAllocate, VIR_DOMAIN_NET_QEMU_ALLOC_LAST,
+              "true",
+              "false")
+
 #define virDomainReportError(conn, code, fmt...)                             \
         virReportErrorHelper(conn, VIR_FROM_DOMAIN, code, __FILE__,        \
                                __FUNCTION__, __LINE__, fmt)
@@ -787,6 +791,7 @@
     char *address = NULL;
     char *port = NULL;
     char *model = NULL;
+    char *qemu_alloc = NULL;
 
     if (VIR_ALLOC(def) < 0) {
         virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
@@ -800,6 +805,17 @@
                                  _("unknown interface type '%s'"), type);
             goto error;
         }
+	qemu_alloc =  virXMLPropString(node, "qemu");
+	if( qemu_alloc!=NULL){
+		 if ((def->qemu_allocate = virDomainNetQemuAllocateTypeFromString(qemu_alloc)) < 0) {
+           		 virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
+                                 _("unknown qemu alloc  '%s'"), qemu_alloc);
+        	    goto error;
+	        }
+
+	}else{
+		def->qemu_allocate = VIR_DOMAIN_NET_QEMU_ALLOC_TRUE; // by default the aloocation will be true
+	} 
     } else {
         def->type = VIR_DOMAIN_NET_TYPE_USER;
     }
@@ -818,6 +834,7 @@
                        (def->type == VIR_DOMAIN_NET_TYPE_BRIDGE) &&
                        (xmlStrEqual(cur->name, BAD_CAST "source"))) {
                 bridge = virXMLPropString(cur, "bridge");
+
             } else if ((dev == NULL) &&
                        (def->type == VIR_DOMAIN_NET_TYPE_ETHERNET) &&
                        xmlStrEqual(cur->name, BAD_CAST "source")) {
--- xend_internal.c.back	2008-12-04 15:31:38.000000000 +0000
+++ xend_internal.c	2008-12-04 21:05:49.000000000 +0000
@@ -1773,10 +1773,9 @@
             if (VIR_ALLOC(net) < 0)
                 goto no_memory;
 
-            if ((tmp2 && strstr(tmp2, "bridge")) || tmp) {
-                net->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
-                /* XXX virtual network reverse resolve */
-
+            if ((tmp2 && (strstr(tmp2, "bridge") )) || tmp) {
+	                net->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
+	        /* XXX virtual network reverse resolve */
                 if (tmp &&
                     !(net->data.bridge.brname = strdup(tmp)))
                     goto no_memory;
@@ -5153,10 +5152,15 @@
 
     /*
      * apparently (type ioemu) breaks paravirt drivers on HVM so skip this
-     * from Xen 3.1.0
+     * from Xen 3.1.0 This happence as XEN try to allocate a network card via qemu 
      */
-    if ((hvm) && (xendConfigVersion < 4))
-        virBufferAddLit(buf, "(type ioemu)");
+//    if ((hvm) && (xendConfigVersion < 4) )
+    if ((hvm) && (def->qemu_allocate==VIR_DOMAIN_NET_QEMU_ALLOC_FALSE)){ /* If we have asked the qemu not to allocte a net work for hvm guest.
+	 This way you would not have a problem with PV drivers on HVM guests*/
+	    virBufferAddLit(buf, "(type none)");
+    }else {
+		virBufferAddLit(buf, "(type ioemu)");
+	}
 
     if (!isAttach)
         virBufferAddLit(buf, ")");
--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]