[libvirt] [PATCH 0/1] SCSI host pools
by David Allan
Hi All,
Here is reworked SCSI host pool code. I have tested it with FC, iSCSI
and SATA, and it works correctly in all those cases. I have not tried
parallel SCSI, but I don't see any reason why it wouldn't work there
also, as it should be transport independent. This patch is so
different from the earlier revision that a diff from the earlier
version would be pointless, and I have only included a patch against
the current head.
Dave
16 years
[libvirt] PATCH: Fix misc memory alloc/free/usage bugs
by Daniel P. Berrange
A few more small bugs
* src/node_device.c: Don't strdup() a NULL device parent
* src/qemu_conf.c: Don't try to run access() on a NULL binary path
* src/security_selinux.c Make sure result from readlink() is NULL
terminated
* src/storage_conf.c: DOn't free 'mode' while it is still used
diff -r b73fe666feff src/node_device.c
--- a/src/node_device.c Fri Mar 27 16:14:49 2009 +0000
+++ b/src/node_device.c Mon Mar 30 14:37:45 2009 +0100
@@ -176,9 +176,14 @@ static char *nodeDeviceGetParent(virNode
goto cleanup;
}
- ret = strdup(obj->def->parent);
- if (!ret)
- virReportOOMError(dev->conn);
+ if (obj->def->parent) {
+ ret = strdup(obj->def->parent);
+ if (!ret)
+ virReportOOMError(dev->conn);
+ } else {
+ virNodeDeviceReportError(dev->conn, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("no parent for this device"));
+ }
cleanup:
if (obj)
diff -r b73fe666feff src/qemu_conf.c
--- a/src/qemu_conf.c Fri Mar 27 16:14:49 2009 +0000
+++ b/src/qemu_conf.c Mon Mar 30 14:37:45 2009 +0100
@@ -269,7 +269,7 @@ qemudCapsInitGuest(virCapsPtr caps,
* which can be used with magic cpu choice
*/
hasbase = (access(info->binary, X_OK) == 0);
- hasaltbase = (access(info->altbinary, X_OK) == 0);
+ hasaltbase = (info->altbinary && access(info->altbinary, X_OK) == 0);
/* Can use acceleration for KVM/KQEMU if
* - host & guest arches match
diff -r b73fe666feff src/security_selinux.c
--- a/src/security_selinux.c Fri Mar 27 16:14:49 2009 +0000
+++ b/src/security_selinux.c Mon Mar 30 14:37:45 2009 +0100
@@ -303,11 +303,13 @@ SELinuxRestoreSecurityImageLabel(virConn
return -1;
if (S_ISLNK(buf.st_mode)) {
+ int n;
if (VIR_ALLOC_N(newpath, buf.st_size + 1) < 0)
return -1;
- if (readlink(path, newpath, buf.st_size) < 0)
+ if ((n =readlink(path, newpath, buf.st_size)) < 0)
goto err;
+ buf.st_size[n] = '\0';
path = newpath;
if (stat(path, &buf) != 0)
goto err;
diff -r b73fe666feff src/storage_conf.c
--- a/src/storage_conf.c Fri Mar 27 16:14:49 2009 +0000
+++ b/src/storage_conf.c Mon Mar 30 14:37:45 2009 +0100
@@ -401,12 +401,13 @@ virStorageDefParsePerms(virConnectPtr co
} else {
char *end = NULL;
perms->mode = strtol(mode, &end, 8);
- VIR_FREE(mode);
if (*end || perms->mode < 0 || perms->mode > 0777) {
+ VIR_FREE(mode);
virStorageReportError(conn, VIR_ERR_XML_ERROR,
"%s", _("malformed octal mode"));
goto error;
}
+ VIR_FREE(mode);
}
if (virXPathNode(conn, "./owner", ctxt) == NULL) {
Daniel
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
16 years
[libvirt] PATCH: Add --tree flag to virsh nodedev-list
by Daniel P. Berrange
The virsh noddev-list command is used to display node devices. It just
prints out their names in a flat list. When detaching devices for purposes
of PCI passthrough though, it is important to understand what devices are
children of the PCI device about to be detached. It is tedious to find
this out, the user having to run virsh nodedev-dumpxml and look at the
parent field.
# virsh -c qemu:///system nodedev-list
computer
DVD_GCC_4247N
net_00_13_02_b9_f9_d3
net_00_13_02_b9_f9_d3_0
net_00_15_58_2f_e9_55
pci_1002_71c4
pci_104c_ac56
pci_8086_27c5_scsi_host
pci_8086_27c5_scsi_host_0
pci_8086_27c5_scsi_host_1
pci_8086_27c5_scsi_host_2
pci_8086_27c5_scsi_host_scsi_device_lun0
pci_8086_27c5_scsi_host_scsi_host
pci_8086_27c8
pci_8086_27da
pci_8086_27df
pci_8086_27df_scsi_host
pci_8086_27df_scsi_host_0
pci_8086_27df_scsi_host_scsi_device_lun0
pci_8086_27df_scsi_host_scsi_host
pci_8086_4227
storage_serial_SATA_HTS721010G9SA00_MPCZ12Y0GNGWSE
usb_device_a5c_2110_noserial_if3
This patch adds a new '--tree' flag to the nodedev-list command, allowing
a prettier format to be used
# virsh -c qemu:///system nodedev-list --tree
computer
|
+-pci_8086_2448
| |
| +-pci_104c_ac56
|
+-pci_8086_27a0
+-pci_8086_27a1
| |
| +-pci_1002_71c4
|
+-pci_8086_27b9
+-pci_8086_27c5
| |
| +-pci_8086_27c5_scsi_host
| | |
| | +-pci_8086_27c5_scsi_host_scsi_device_lun0
| | | |
| | | +-storage_serial_SATA_HTS721010G9SA00_MPCZ12Y0GNGWSE
| | |
| | +-pci_8086_27c5_scsi_host_scsi_host
| |
| +-pci_8086_27c5_scsi_host_0
| +-pci_8086_27c5_scsi_host_1
| +-pci_8086_27c5_scsi_host_2
|
+-pci_8086_27c8
| |
| +-usb_device_1d6b_1_0000_00_1d_0
| |
| +-usb_device_1d6b_1_0000_00_1d_0_if0
|
+-pci_8086_27c9
| |
| +-usb_device_1d6b_1_0000_00_1d_1
| |
| +-usb_device_1d6b_1_0000_00_1d_1_if0
|
+-pci_8086_27ca
| |
| +-usb_device_1d6b_1_0000_00_1d_2
| |
| +-usb_device_1d6b_1_0000_00_1d_2_if0
|
+-pci_8086_27cb
| |
| +-usb_device_1d6b_1_0000_00_1d_3
| |
| +-usb_device_1d6b_1_0000_00_1d_3_if0
| +-usb_device_483_2016_noserial
| | |
| | +-usb_device_483_2016_noserial_if0
| |
| +-usb_device_a5c_2110_noserial
| |
| +-usb_device_a5c_2110_noserial_if0
| +-usb_device_a5c_2110_noserial_if1
| +-usb_device_a5c_2110_noserial_if2
| +-usb_device_a5c_2110_noserial_if3
|
+-pci_8086_27cc
| |
| +-usb_device_1d6b_2_0000_00_1d_7
| |
| +-usb_device_1d6b_2_0000_00_1d_7_if0
|
+-pci_8086_27d0
| |
| +-pci_8086_109a
| |
| +-net_00_15_58_2f_e9_55
|
+-pci_8086_27d2
| |
| +-pci_8086_4227
| |
| +-net_00_13_02_b9_f9_d3
| +-net_00_13_02_b9_f9_d3_0
|
+-pci_8086_27d4
+-pci_8086_27d6
+-pci_8086_27d8
+-pci_8086_27da
+-pci_8086_27df
|
+-pci_8086_27df_scsi_host
| |
| +-pci_8086_27df_scsi_host_scsi_device_lun0
| | |
| | +-DVD_GCC_4247N
| |
| +-pci_8086_27df_scsi_host_scsi_host
|
+-pci_8086_27df_scsi_host_0
Daniel
diff -r b73fe666feff src/virsh.c
--- a/src/virsh.c Fri Mar 27 16:14:49 2009 +0000
+++ b/src/virsh.c Mon Mar 30 14:37:45 2009 +0100
@@ -4391,16 +4391,77 @@ static const vshCmdInfo info_node_list_d
};
static const vshCmdOptDef opts_node_list_devices[] = {
+ {"tree", VSH_OT_BOOL, 0, gettext_noop("list devices in a tree")},
{"cap", VSH_OT_STRING, VSH_OFLAG_NONE, gettext_noop("capability name")},
{NULL, 0, 0, NULL}
};
+#define MAX_INDENT 100
+
+static void
+cmdNodeListDevicesPrint(vshControl *ctl,
+ char **devices,
+ char **parents,
+ int num_devices,
+ int devid,
+ int lastdev,
+ unsigned int depth,
+ char *indent)
+{
+ int i;
+ int nextlastdev = -1;
+
+ if (depth) {
+ indent[depth] = '+';
+ indent[depth+1] = '-';
+ }
+
+ vshPrint(ctl, indent);
+ if (depth) {
+ if (devid == lastdev)
+ indent[depth] = ' ';
+ else
+ indent[depth] = '|';
+ indent[depth+1] = ' ';
+ depth+=2;
+ }
+ vshPrint(ctl, "%s\n", devices[devid]);
+
+ for (i = 0 ; i < num_devices ; i++) {
+ if (parents[i] &&
+ STREQ(parents[i], devices[devid])) {
+ //fprintf(stderr, "%s %s %d %d\n", parents[i], devices[devid], i, devid);
+ nextlastdev = i;
+ }
+ }
+
+ if (nextlastdev != -1) {
+ vshPrint(ctl, indent);
+ vshPrint(ctl, " |\n");
+ }
+
+ indent[depth] = ' ';
+ for (i = 0 ; i < num_devices ; i++) {
+ indent[depth] = ' ';
+ indent[depth+1] = ' ';
+ if (parents[i] &&
+ STREQ(parents[i], devices[devid]))
+ cmdNodeListDevicesPrint(ctl, devices, parents, num_devices, i, nextlastdev, depth + 2, indent);
+ indent[depth] = '\0';
+ }
+ if (nextlastdev == -1 && devid == lastdev) {
+ vshPrint(ctl, indent);
+ vshPrint(ctl, "\n");
+ }
+}
+
static int
cmdNodeListDevices (vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
char *cap;
char **devices;
int found, num_devices, i;
+ int tree = vshCommandOptBool(cmd, "tree");
if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
return FALSE;
@@ -4426,9 +4487,39 @@ cmdNodeListDevices (vshControl *ctl, con
return FALSE;
}
qsort(&devices[0], num_devices, sizeof(char*), namesorter);
- for (i = 0; i < num_devices; i++) {
- vshPrint(ctl, "%s\n", devices[i]);
- free(devices[i]);
+ if (tree) {
+ char indent[MAX_INDENT];
+ char **parents = vshMalloc(ctl, sizeof(char *) * num_devices);
+ for (i = 0; i < num_devices; i++) {
+ virNodeDevicePtr dev = virNodeDeviceLookupByName(ctl->conn, devices[i]);
+ if (dev && STRNEQ(devices[i], "computer")) {
+ const char *parent = virNodeDeviceGetParent(dev);
+ parents[i] = parent ? strdup(parent) : NULL;
+ } else {
+ parents[i] = NULL;
+ }
+ virNodeDeviceFree(dev);
+ }
+ for (i = 0 ; i < num_devices ; i++) {
+ memset(indent, '\0', sizeof indent);
+ if (parents[i] == NULL)
+ cmdNodeListDevicesPrint(ctl,
+ devices,
+ parents,
+ num_devices,
+ i,
+ i,
+ 0,
+ indent);
+ }
+ for (i = 0 ; i < num_devices ; i++)
+ free(parents[i]);
+ free(parents);
+ } else {
+ for (i = 0; i < num_devices; i++) {
+ vshPrint(ctl, "%s\n", devices[i]);
+ free(devices[i]);
+ }
}
free(devices);
return TRUE;
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
16 years
[libvirt] question about qemudDomainMigratePrepare2 of qemu_driver.c from libvirt-0.6.1
by Gerrit.Slomma@drv-bund.de
Hello
I am just curious if the checking of the connection string in qemu_driver.c
from libvirt-0.6.1 in qemudDomainMigratePrepare2 is faulty.
The source is:
[...]
} else {
/* Check the URI starts with "tcp:". We will escape the
* URI when passing it to the qemu monitor, so bad
* characters in hostname part don't matter.
*/
if (!STREQLEN (uri_in, "tcp:", 6)) {
qemudReportError (dconn, NULL, NULL, VIR_ERR_INVALID_ARG,
"%s", _("only tcp URIs are supported for KVM
migrations"));
goto cleanup;
}
[...]
The second compare-string "tcp:" is only 4 characters long, therefore a
check via strncmp must fail i presumed, i isolated this comparison:
#include <stdio.h>
#include <string.h>
#define STREQLEN(a,b,n) (strncmp((a),(b),(n)) == 0)
int main ()
{
char str[][200] = { "tcp://192.168.1.14:4444" , "tcp:192.168.1.14:4444" ,
"ssh
://192.168.1.14:4444" , "ssh:192.168.1.14:4444" };
int n;
for (n=0 ; n<4 ; n++)
{
printf("testing %s against \"tcp:\" with result: ", str[n]);
if (!STREQLEN(str[n],"tcp:",6))
{
printf ("ERROR\n");
}
else
{
printf ("OK\n");
}
}
return 0;
}
and as i pressumed this gives me on the commandline:
testing tcp://192.168.1.14:4444 against "tcp:" with result: ERROR
testing tcp:192.168.1.14:4444 against "tcp:" with result: ERROR
testing ssh://192.168.1.14:4444 against "tcp:" with result: ERROR
testing ssh:192.168.1.14:4444 against "tcp:" with result: ERROR
if i change the 6 to 4 it gives
testing tcp://192.168.1.14:4444 against "tcp:" with result: OK
testing tcp:192.168.1.14:4444 against "tcp:" with result: OK
testing ssh://192.168.1.14:4444 against "tcp:" with result: ERROR
testing ssh:192.168.1.14:4444 against "tcp:" with result: ERROR
but now tcp:// also is marked as correct.
Am i missing something here and the checking in qemu_driver.c is correct?
I always get the "only tcp URIs are supported for KVM migrations" if i try
to migrate KVM-domains in virt-manager 0.7.0 and therefore searched for the
root-cause of this problem.
Kind regards, Gerrit Slomma
Mit freundlichen Grüßen, Gerrit Slomma
Team eBetrieb
Deutsche Rentenversicherung Bund
Abt. 11 - Organisation und IT-Services
Fachbereich 1170 - IT-Services und Betrieb
Bereich 1174 - Anwendungsbetrieb
Team 1174-46 - Trustcenter, eBetrieb
16 years
[libvirt] PATCH: Fix XM driver to extract vifname= parameter
by Daniel P. Berrange
The XM driver is not currently handling the vifname= parameter for
network devices in /etc/xen config files. This patch fixes that
ommision
Daniel
diff -r e396919fa59e src/xm_internal.c
--- a/src/xm_internal.c Tue Mar 31 16:35:42 2009 +0100
+++ b/src/xm_internal.c Tue Mar 31 16:58:11 2009 +0100
@@ -991,6 +991,7 @@ xenXMDomainConfigParse(virConnectPtr con
char ip[16];
char mac[18];
char bridge[50];
+ char vifname[50];
char *key;
bridge[0] = '\0';
@@ -998,6 +999,7 @@ xenXMDomainConfigParse(virConnectPtr con
script[0] = '\0';
ip[0] = '\0';
model[0] = '\0';
+ vifname[0] = '\0';
if ((list->type != VIR_CONF_STRING) || (list->str == NULL))
goto skipnic;
@@ -1036,6 +1038,12 @@ xenXMDomainConfigParse(virConnectPtr con
len = sizeof(model)-1;
strncpy(model, data, len);
model[len] = '\0';
+ } else if (STRPREFIX(key, "vifname=")) {
+ int len = nextkey ? (nextkey - data) : sizeof(vifname)-1;
+ if (len > (sizeof(vifname)-1))
+ len = sizeof(vifname)-1;
+ strncpy(vifname, data, len);
+ vifname[len] = '\0';
} else if (STRPREFIX(key, "ip=")) {
int len = nextkey ? (nextkey - data) : 15;
if (len > 15)
@@ -1105,6 +1113,10 @@ xenXMDomainConfigParse(virConnectPtr con
!(net->model = strdup(model)))
goto no_memory;
+ if (vifname[0] &&
+ !(net->ifname = strdup(vifname)))
+ goto no_memory;
+
if (VIR_REALLOC_N(def->nets, def->nnets+1) < 0)
goto no_memory;
def->nets[def->nnets++] = net;
@@ -1994,6 +2006,10 @@ static int xenXMDomainConfigFormatNet(vi
virBufferVSprintf(&buf, ",model=%s",
net->model);
+ if (net->ifname)
+ virBufferVSprintf(&buf, ",vifname=%s",
+ net->ifname);
+
if (VIR_ALLOC(val) < 0) {
virReportOOMError(conn);
goto cleanup;
diff -r e396919fa59e tests/xmconfigdata/test-paravirt-net-vifname.cfg
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/xmconfigdata/test-paravirt-net-vifname.cfg Tue Mar 31 16:58:11 2009 +0100
@@ -0,0 +1,12 @@
+name = "XenGuest1"
+uuid = "c7a5fdb0-cdaf-9455-926a-d65c16db1809"
+maxmem = 579
+memory = 394
+vcpus = 1
+bootloader = "/usr/bin/pygrub"
+on_poweroff = "destroy"
+on_reboot = "restart"
+on_crash = "restart"
+vfb = [ "type=vnc,vncunused=1,vnclisten=127.0.0.1,vncpasswd=123poi" ]
+disk = [ "phy:/dev/HostVG/XenGuest1,xvda,w" ]
+vif = [ "mac=00:16:3e:66:94:9c,bridge=br0,model=e1000,vifname=net0" ]
diff -r e396919fa59e tests/xmconfigdata/test-paravirt-net-vifname.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/xmconfigdata/test-paravirt-net-vifname.xml Tue Mar 31 16:58:11 2009 +0100
@@ -0,0 +1,33 @@
+<domain type='xen'>
+ <name>XenGuest1</name>
+ <uuid>c7a5fdb0-cdaf-9455-926a-d65c16db1809</uuid>
+ <memory>592896</memory>
+ <currentMemory>403456</currentMemory>
+ <vcpu>1</vcpu>
+ <bootloader>/usr/bin/pygrub</bootloader>
+ <os>
+ <type arch='i686' machine='xenpv'>linux</type>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>restart</on_crash>
+ <devices>
+ <disk type='block' device='disk'>
+ <driver name='phy'/>
+ <source dev='/dev/HostVG/XenGuest1'/>
+ <target dev='xvda' bus='xen'/>
+ </disk>
+ <interface type='bridge'>
+ <mac address='00:16:3e:66:94:9c'/>
+ <source bridge='br0'/>
+ <target dev='net0'/>
+ <model type='e1000'/>
+ </interface>
+ <console type='pty'>
+ <target port='0'/>
+ </console>
+ <input type='mouse' bus='xen'/>
+ <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/>
+ </devices>
+</domain>
diff -r e396919fa59e tests/xmconfigtest.c
--- a/tests/xmconfigtest.c Tue Mar 31 16:35:42 2009 +0100
+++ b/tests/xmconfigtest.c Tue Mar 31 16:58:11 2009 +0100
@@ -209,6 +209,7 @@ mymain(int argc, char **argv)
DO_TEST("paravirt-new-pvfb", 3);
DO_TEST("paravirt-new-pvfb-vncdisplay", 3);
DO_TEST("paravirt-net-e1000", 3);
+ DO_TEST("paravirt-net-vifname", 3);
DO_TEST("fullvirt-old-cdrom", 1);
DO_TEST("fullvirt-new-cdrom", 2);
DO_TEST("fullvirt-utc", 2);
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
16 years
[libvirt] PATCH: Fix error reporting for guest with missing network
by Daniel P. Berrange
If you attempt to create a Xen guest using a virutal network that does not
exist, or is not running you get a cryptic message
# virsh create rhel5pv.xml
error: Failed to create domain from rhel5pv.xml
error: XML description for failed to build sexpr is not well formed or invalid
This is because the XenD/XM drivers are both overwriting errors that have
already been reported. The fix is simply to remove this bogus error call.
It also tweaks the original error reporting to be more meaningful.
The result is this
# virsh create rhel5pv.xml
error: Failed to create domain from rhel5pv.xml
error: Network not found: default
Daniel
diff -r 28e19af5b719 src/xend_internal.c
--- a/src/xend_internal.c Tue Mar 31 15:13:21 2009 +0100
+++ b/src/xend_internal.c Tue Mar 31 16:35:41 2009 +0100
@@ -3983,8 +3983,6 @@ xenDaemonCreateXML(virConnectPtr conn, c
return (NULL);
if (!(sexpr = xenDaemonFormatSxpr(conn, def, priv->xendConfigVersion))) {
- virXendError(conn, VIR_ERR_XML_ERROR,
- "%s", _("failed to build sexpr"));
virDomainDefFree(def);
return (NULL);
}
@@ -5362,7 +5360,7 @@ xenDaemonFormatSxprNet(virConnectPtr con
char *bridge;
if (!network) {
- virXendError(conn, VIR_ERR_NO_SOURCE, "%s",
+ virXendError(conn, VIR_ERR_NO_NETWORK, "%s",
def->data.network.name);
return -1;
}
@@ -5370,7 +5368,8 @@ xenDaemonFormatSxprNet(virConnectPtr con
bridge = virNetworkGetBridgeName(network);
virNetworkFree(network);
if (!bridge) {
- virXendError(conn, VIR_ERR_NO_SOURCE, "%s",
+ virXendError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("network %s is not active"),
def->data.network.name);
return -1;
}
diff -r 28e19af5b719 src/xm_internal.c
--- a/src/xm_internal.c Tue Mar 31 15:13:21 2009 +0100
+++ b/src/xm_internal.c Tue Mar 31 16:35:41 2009 +0100
@@ -1818,11 +1818,8 @@ int xenXMDomainCreate(virDomainPtr domai
if (!(entry = virHashLookup(priv->configCache, filename)))
goto error;
- if (!(sexpr = xenDaemonFormatSxpr(domain->conn, entry->def, priv->xendConfigVersion))) {
- xenXMError(domain->conn, VIR_ERR_XML_ERROR,
- "%s", _("failed to build sexpr"));
+ if (!(sexpr = xenDaemonFormatSxpr(domain->conn, entry->def, priv->xendConfigVersion)))
goto error;
- }
ret = xenDaemonDomainCreateXML(domain->conn, sexpr);
VIR_FREE(sexpr);
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
16 years
[libvirt] PATCH: Fix error report for unknown node devices
by Daniel P. Berrange
When requesting a non-existant device you currently get
# virsh nodedev-dumpxml foo
error: Could not find matching device 'foo'
error: invalid node device pointer in no node device with matching name
This patch fixes that to give
# virsh nodedev-dumpxml foo
error: Could not find matching device 'foo'
error: Node device not found
Daniel
diff -r 563f92056ffa src/node_device.c
--- a/src/node_device.c Tue Mar 31 15:02:30 2009 +0100
+++ b/src/node_device.c Tue Mar 31 15:13:20 2009 +0100
@@ -121,8 +121,7 @@ static virNodeDevicePtr nodeDeviceLookup
nodeDeviceUnlock(driver);
if (!obj) {
- virNodeDeviceReportError(conn, VIR_ERR_INVALID_NODE_DEVICE,
- "%s", _("no node device with matching name"));
+ virNodeDeviceReportError(conn, VIR_ERR_NO_NODE_DEVICE, NULL);
goto cleanup;
}
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
16 years
[libvirt] PATCH: Update XenD for new location of (localtime 1) SEXPR
by Daniel P. Berrange
Newer versions of XenD have the (localtime 1) bit of the SEXPR
moved outside the (image ...) bit, and made available for both PV
and HVM guests. This patch updates our code to cope with this. For
compatability we also still put the (localtime 1) bit inside the
HVM (image ...) section too - its harmless on new XenD, and stops
us breaking old deployments. Finally, this also updates the XM
driver to accept localtime=1 for PV guests.
Daniel
diff -r 00b8aaa2555b src/xend_internal.c
--- a/src/xend_internal.c Tue Mar 31 12:02:49 2009 +0100
+++ b/src/xend_internal.c Tue Mar 31 12:26:01 2009 +0100
@@ -2423,10 +2423,15 @@ xenDaemonParseSxpr(virConnectPtr conn,
if (sexpr_int(root, "domain/image/hvm/pae"))
def->features |= (1 << VIR_DOMAIN_FEATURE_PAE);
+ /* Old XenD only allows localtime here for HVM */
if (sexpr_int(root, "domain/image/hvm/localtime"))
def->localtime = 1;
}
+ /* Current XenD allows localtime here, for PV and HVM */
+ if (sexpr_int(root, "domain/localtime"))
+ def->localtime = 1;
+
if (sexpr_node_copy(root, hvm ?
"domain/image/hvm/device_model" :
"domain/image/linux/device_model",
@@ -5603,6 +5608,10 @@ xenDaemonFormatSxpr(virConnectPtr conn,
}
virBufferVSprintf(&buf, "(on_crash '%s')", tmp);
+ /* Set localtime here for current XenD (both PV & HVM) */
+ if (def->localtime)
+ virBufferAddLit(&buf, "(localtime 1)");
+
if (!def->os.bootloader) {
if (STREQ(def->os.type, "hvm"))
hvm = 1;
@@ -5718,6 +5727,7 @@ xenDaemonFormatSxpr(virConnectPtr conn,
virBufferAddLit(&buf, "(serial none)");
}
+ /* Set localtime here to keep old XenD happy for HVM */
if (def->localtime)
virBufferAddLit(&buf, "(localtime 1)");
diff -r 00b8aaa2555b src/xm_internal.c
--- a/src/xm_internal.c Tue Mar 31 12:02:49 2009 +0100
+++ b/src/xm_internal.c Tue Mar 31 12:26:01 2009 +0100
@@ -819,10 +819,10 @@ xenXMDomainConfigParse(virConnectPtr con
goto cleanup;
else if (val)
def->features |= (1 << VIR_DOMAIN_FEATURE_APIC);
+ }
+ if (xenXMConfigGetBool(conn, conf, "localtime", &def->localtime, 0) < 0)
+ goto cleanup;
- if (xenXMConfigGetBool(conn, conf, "localtime", &def->localtime, 0) < 0)
- goto cleanup;
- }
if (xenXMConfigCopyStringOpt(conn, conf, "device_model", &def->emulator) < 0)
goto cleanup;
diff -r 00b8aaa2555b tests/sexpr2xmldata/sexpr2xml-pv-localtime.sexpr
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/sexpr2xmldata/sexpr2xml-pv-localtime.sexpr Tue Mar 31 12:26:01 2009 +0100
@@ -0,0 +1,2 @@
+(domain (domid 6)(name 'pvtest')(memory 420)(maxmem 420)(vcpus 2)(uuid '596a5d2171f48fb2e068e2386a5c413e')(on_poweroff 'destroy')(on_reboot 'destroy')(on_crash 'destroy')(localtime 1)(image (linux (kernel '/var/lib/xen/vmlinuz.2Dn2YT')(ramdisk '/var/lib/xen/initrd.img.0u-Vhq')(args ' method=http://download.fedora.devel.redhat.com/pub/fedora/linux/core/test... ')))(device (vbd (dev 'xvda')(uname 'file:/root/some.img')(mode 'w'))))
+
diff -r 00b8aaa2555b tests/sexpr2xmldata/sexpr2xml-pv-localtime.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/sexpr2xmldata/sexpr2xml-pv-localtime.xml Tue Mar 31 12:26:01 2009 +0100
@@ -0,0 +1,27 @@
+<domain type='xen' id='6'>
+ <name>pvtest</name>
+ <uuid>596a5d21-71f4-8fb2-e068-e2386a5c413e</uuid>
+ <memory>430080</memory>
+ <currentMemory>430080</currentMemory>
+ <vcpu>2</vcpu>
+ <os>
+ <type>linux</type>
+ <kernel>/var/lib/xen/vmlinuz.2Dn2YT</kernel>
+ <initrd>/var/lib/xen/initrd.img.0u-Vhq</initrd>
+ <cmdline> method=http://download.fedora.devel.redhat.com/pub/fedora/linux/core/test... </cmdline>
+ </os>
+ <clock offset='localtime'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>destroy</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <disk type='file' device='disk'>
+ <driver name='file'/>
+ <source file='/root/some.img'/>
+ <target dev='xvda' bus='xen'/>
+ </disk>
+ <console type='pty'>
+ <target port='0'/>
+ </console>
+ </devices>
+</domain>
diff -r 00b8aaa2555b tests/sexpr2xmltest.c
--- a/tests/sexpr2xmltest.c Tue Mar 31 12:02:49 2009 +0100
+++ b/tests/sexpr2xmltest.c Tue Mar 31 12:26:01 2009 +0100
@@ -145,6 +145,7 @@ mymain(int argc, char **argv)
DO_TEST("bridge-ipaddr", "bridge-ipaddr", 3);
DO_TEST("no-source-cdrom", "no-source-cdrom", 2);
DO_TEST("pci-devs", "pci-devs", 2);
+ DO_TEST("pv-localtime", "pv-localtime", 2);
DO_TEST("fv-utc", "fv-utc", 1);
DO_TEST("fv-localtime", "fv-localtime", 1);
diff -r 00b8aaa2555b tests/xml2sexprdata/xml2sexpr-fv-localtime.sexpr
--- a/tests/xml2sexprdata/xml2sexpr-fv-localtime.sexpr Tue Mar 31 12:02:49 2009 +0100
+++ b/tests/xml2sexprdata/xml2sexpr-fv-localtime.sexpr Tue Mar 31 12:26:01 2009 +0100
@@ -1,1 +1,1 @@
-(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd2-75cd-aca5-1776-9660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(parallel none)(serial none)(localtime 1)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
+(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd2-75cd-aca5-1776-9660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(localtime 1)(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(parallel none)(serial none)(localtime 1)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
diff -r 00b8aaa2555b tests/xml2sexprdata/xml2sexpr-pv-localtime.sexpr
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/xml2sexprdata/xml2sexpr-pv-localtime.sexpr Tue Mar 31 12:26:01 2009 +0100
@@ -0,0 +1,1 @@
+(vm (name 'rhel5')(memory 175)(maxmem 385)(vcpus 1)(uuid '4f77abd2-3019-58e8-3bab-6fbf2118f880')(bootloader '/usr/bin/pygrub')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(localtime 1)(device (tap (dev 'xvda:disk')(uname 'tap:aio:/xen/rhel5.img')(mode 'w')))(device (vif (mac '00:16:3e:1d:06:15')(bridge 'xenbr0')(script 'vif-bridge'))))
\ No newline at end of file
diff -r 00b8aaa2555b tests/xml2sexprdata/xml2sexpr-pv-localtime.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/xml2sexprdata/xml2sexpr-pv-localtime.xml Tue Mar 31 12:26:01 2009 +0100
@@ -0,0 +1,25 @@
+<domain type='xen' id='5'>
+ <name>rhel5</name>
+ <uuid>4f77abd2301958e83bab6fbf2118f880</uuid>
+ <bootloader>/usr/bin/pygrub</bootloader>
+ <memory>394240</memory>
+ <currentMemory>179200</currentMemory>
+ <vcpu>1</vcpu>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>restart</on_crash>
+ <clock offset='localtime'/>
+ <devices>
+ <interface type='bridge'>
+ <source bridge='xenbr0'/>
+ <mac address='00:16:3e:1d:06:15'/>
+ <script path='vif-bridge'/>
+ </interface>
+ <disk type='file' device='disk'>
+ <driver name='tap' type='aio'/>
+ <source file='/xen/rhel5.img'/>
+ <target dev='xvda:disk'/>
+ </disk>
+ <graphics type='vnc' port='5905'/>
+ </devices>
+</domain>
diff -r 00b8aaa2555b tests/xml2sexprtest.c
--- a/tests/xml2sexprtest.c Tue Mar 31 12:02:49 2009 +0100
+++ b/tests/xml2sexprtest.c Tue Mar 31 12:26:01 2009 +0100
@@ -130,6 +130,7 @@ mymain(int argc, char **argv)
DO_TEST("bridge-ipaddr", "bridge-ipaddr", "pvtest", 2);
DO_TEST("no-source-cdrom", "no-source-cdrom", "test", 2);
DO_TEST("pci-devs", "pci-devs", "pvtest", 2);
+ DO_TEST("pv-localtime", "pv-localtime", "pvtest", 1);
DO_TEST("fv-utc", "fv-utc", "fvtest", 1);
DO_TEST("fv-localtime", "fv-localtime", "fvtest", 1);
Daniel
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
16 years
[libvirt] PATCH: Fix duplicate methods in python binding
by Daniel P. Berrange
There are three methods with the same name in the python binding
due to a generator bug. This patch fixes them, so we get methods
networkCreateXML() and storagePoolCreateXML() instad of three
called createXML()
Daniel
diff -r e26692afef21 python/generator.py
--- a/python/generator.py Tue Mar 31 12:26:01 2009 +0100
+++ b/python/generator.py Tue Mar 31 12:36:02 2009 +0100
@@ -684,12 +684,18 @@ def nameFixup(name, classe, type, file):
elif name[0:16] == "virNetworkDefine":
func = name[3:]
func = string.lower(func[0:1]) + func[1:]
+ elif name[0:19] == "virNetworkCreateXML":
+ func = name[3:]
+ func = string.lower(func[0:1]) + func[1:]
elif name[0:16] == "virNetworkLookup":
func = name[3:]
func = string.lower(func[0:1]) + func[1:]
elif name[0:20] == "virStoragePoolDefine":
func = name[3:]
func = string.lower(func[0:1]) + func[1:]
+ elif name[0:23] == "virStoragePoolCreateXML":
+ func = name[3:]
+ func = string.lower(func[0:1]) + func[1:]
elif name[0:20] == "virStoragePoolLookup":
func = name[3:]
func = string.lower(func[0:1]) + func[1:]
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
16 years