Re: <model>e1000</model> - Specifying model in XML Configs

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

 



Sorry - I tried to make a patch, but it appears it makes libvirtd
segfault (it starts but when i try to use virsh -c qemu:///system create
vm.cfg it segfaults).

Also - when building my own copy of libvirt - I can connect via virsh -c
qemu:///system, but just 'virsh' says it cannot connect to the
hypervisor - any idea what could cause that? I'm root at the time

As I said, my C-fu is weak - it's probably not useable, if anyone feels
really generous i'd appreciate some criticism, otherwise probably best
if one of you guys made it :p

I think for the meantime i'm going to hard code model=e1000 into my
build, since all my VMs will use that (no windows ones)

Henri

Richard W.M. Jones wrote:
> On Tue, Apr 08, 2008 at 10:19:02AM +0100, Henri Cook wrote:
>   
>> I've made a hack for this in the meantime that adds the <model></model>
>>     
>
> You have a patch?
>
>   
>> Is there a way to fix this without rebooting? ifconfig virbr0 0.0.0.0
>> down && brctl delbr virbr0 - doesn't seem to be enough, what did I miss?
>>     
>
> This should be enough to get rid of the bridge, but if not then you
> need to look at the error messages and the output of 'brctl show'.
>
> Rich.
>
>   

--- libvirt-0.4.0/src/qemu_conf.h	2007-12-04 13:26:35.000000000 +0000
+++ libvirt-0.4.0-new/src/qemu_conf.h	2008-04-08 11:08:40.000000000 +0100
@@ -68,6 +68,7 @@
 
 #define QEMUD_MAC_ADDRESS_LEN 6
 #define QEMUD_OS_TYPE_MAX_LEN 10
+#define	QEMUD_NET_DRIVER_MAX_LEN 10
 #define QEMUD_OS_ARCH_MAX_LEN 10
 #define QEMUD_OS_MACHINE_MAX_LEN 10
 
@@ -90,6 +91,8 @@
 struct qemud_vm_net_def {
     int type;
     unsigned char mac[QEMUD_MAC_ADDRESS_LEN];
+    unsigned char model[QEMUD_NET_DRIVER_MAX_LEN]; 
+    
     union {
         struct {
             char ifname[BR_IFNAME_MAXLEN];

--- libvirt-0.4.0/src/qemu_conf.c	2007-12-12 13:30:49.000000000 +0000
+++ libvirt-0.4.0-new/src/qemu_conf.c	2008-04-08 12:36:02.000000000 +0100
@@ -605,6 +605,7 @@
     xmlChar *script = NULL;
     xmlChar *address = NULL;
     xmlChar *port = NULL;
+    xmlChar *model = NULL;
 
     net->type = QEMUD_NET_USER;
 
@@ -666,6 +667,8 @@
                        (net->type == QEMUD_NET_ETHERNET) &&
                        xmlStrEqual(cur->name, BAD_CAST "script")) {
                 script = xmlGetProp(cur, BAD_CAST "path");
+            } else if (xmlStrEqual(cur->name, BAD_CAST "model")) {
+            	model = xmlGetProp(cur, BAD_CAST "type");
             }
         }
         cur = cur->next;
@@ -822,6 +825,17 @@
         }
         xmlFree(address);
     }
+    
+    // Model can apply to all interface configurations, should we check for all the known supported model types?
+    // Otherwise it's an optional parameter, so no real checking need be done
+    if (model != NULL) {
+    	int len = 0;
+    	if ((len = xmlStrlen(model)) >= QEMUD_NET_DRIVER_MAX_LEN) {
+    		qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+                             _("Interface model type '%s' is too long"), model);
+            goto error;
+    	}		
+    }    
 
     return 0;
 
@@ -838,6 +852,8 @@
         xmlFree(script);
     if (bridge)
         xmlFree(bridge);
+    if (model)
+    	xmlFree(model);
     return -1;
 }
 
@@ -1679,13 +1695,27 @@
         int vlan = 0;
         while (net) {
             char nic[100];
+            char model[QEMUD_NET_DRIVER_MAX_LEN];
 
-            if (snprintf(nic, sizeof(nic), "nic,macaddr=%02x:%02x:%02x:%02x:%02x:%02x,vlan=%d",
+			// Model's optional, if it's not set simply set the temporary 'model' variable to ''
+			if (net->model == NULL)
+			{
+				snprintf(model, sizeof(model), ",");
+			}
+			else
+			{
+				snprintf(model, sizeof(model), ",model=%s,", net->model);
+			}
+			
+            if (snprintf(nic, sizeof(nic), "nic%smacaddr=%02x:%02x:%02x:%02x:%02x:%02x,vlan=%d",
+            			 model,
                          net->mac[0], net->mac[1],
                          net->mac[2], net->mac[3],
                          net->mac[4], net->mac[5],
                          vlan) >= sizeof(nic))
                 goto error;
+                
+            free(model);
 
             if (!((*argv)[++n] = strdup("-net")))
                 goto no_memory;
--
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]