[libvirt] PATCH: Fix XM driver handling of disks without source file
by Daniel P. Berrange
It is possible for disks to be listed without a source file against
them, eg a CDROM device with no media loaded. The XenD driver handles
this, but the XM driver incorrectly generates XML with a <source file=''/>
element instead of omitting the element entirely. This causes a bogus
SXEXPR to be sent to XenD when starting the domain. This patch does
three things
- Makes the generic domain_conf.c XML parser accept XML docs with
a bogus <source file=''/> and convert the source to NULL, instead
of passing along the empty string "". This protects against broken
apps
- Makes the XM driver correctly generate XML in the first place,
so omitting the <source> tag entirely. This is the root cause fix
- Adds a test case for the XM driver to validate handling of devices
with a source file
src/domain_conf.c | 8 +++
src/xm_internal.c | 70 ++++++++++++++++------------
tests/xmconfigdata/test-no-source-cdrom.cfg | 23 +++++++++
tests/xmconfigdata/test-no-source-cdrom.xml | 46 ++++++++++++++++++
tests/xmconfigtest.c | 1
5 files changed, 120 insertions(+), 28 deletions(-)
Daniel
Index: src/xm_internal.c
===================================================================
RCS file: /data/cvs/libvirt/src/xm_internal.c,v
retrieving revision 1.102
diff -u -p -r1.102 xm_internal.c
--- src/xm_internal.c 25 Nov 2008 11:18:08 -0000 1.102
+++ src/xm_internal.c 27 Nov 2008 12:14:57 -0000
@@ -828,7 +828,7 @@ xenXMDomainConfigParse(virConnectPtr con
while (list) {
char *head;
char *offset;
- char *tmp, *tmp1;
+ char *tmp;
if ((list->type != VIR_CONF_STRING) || (list->str == NULL))
goto skipdisk;
@@ -850,10 +850,15 @@ xenXMDomainConfigParse(virConnectPtr con
goto skipdisk;
if ((offset - head) >= (PATH_MAX-1))
goto skipdisk;
- if (VIR_ALLOC_N(disk->src, (offset - head) + 1) < 0)
- goto no_memory;
- strncpy(disk->src, head, (offset - head));
- disk->src[(offset-head)] = '\0';
+
+ if (offset == head) {
+ disk->src = NULL; /* No source file given, eg CDROM with no media */
+ } else {
+ if (VIR_ALLOC_N(disk->src, (offset - head) + 1) < 0)
+ goto no_memory;
+ strncpy(disk->src, head, (offset - head));
+ disk->src[(offset-head)] = '\0';
+ }
head = offset + 1;
/* Remove legacy ioemu: junk */
@@ -871,32 +876,41 @@ xenXMDomainConfigParse(virConnectPtr con
/* Extract source driver type */
- if (disk->src &&
- (tmp = strchr(disk->src, ':')) != NULL) {
- if (VIR_ALLOC_N(disk->driverName, (tmp - disk->src) + 1) < 0)
- goto no_memory;
- strncpy(disk->driverName, disk->src, (tmp - disk->src));
- disk->driverName[tmp - disk->src] = '\0';
- } else {
- if (!(disk->driverName = strdup("phy")))
- goto no_memory;
- tmp = disk->src;
- }
+ if (disk->src) {
+ /* The main type phy:, file:, tap: ... */
+ if ((tmp = strchr(disk->src, ':')) != NULL) {
+ if (VIR_ALLOC_N(disk->driverName, (tmp - disk->src) + 1) < 0)
+ goto no_memory;
+ strncpy(disk->driverName, disk->src, (tmp - disk->src));
+ disk->driverName[tmp - disk->src] = '\0';
- /* And the source driver sub-type */
- if (STRPREFIX(disk->driverName, "tap")) {
- if (!(tmp1 = strchr(tmp+1, ':')) || !tmp1[0])
- goto skipdisk;
- if (VIR_ALLOC_N(disk->driverType, (tmp1-(tmp+1))) < 0)
- goto no_memory;
- strncpy(disk->driverType, tmp+1, (tmp1-(tmp+1)));
- memmove(disk->src, disk->src+(tmp1-disk->src)+1, strlen(disk->src)-(tmp1-disk->src));
- } else {
- disk->driverType = NULL;
- if (disk->src[0] && tmp)
- memmove(disk->src, disk->src+(tmp-disk->src)+1, strlen(disk->src)-(tmp-disk->src));
+ /* Strip the prefix we found off the source file name */
+ memmove(disk->src, disk->src+(tmp-disk->src)+1,
+ strlen(disk->src)-(tmp-disk->src));
+ }
+
+ /* And the sub-type for tap:XXX: type */
+ if (disk->driverName &&
+ STREQ(disk->driverName, "tap")) {
+ if (!(tmp = strchr(disk->src, ':')))
+ goto skipdisk;
+ if (VIR_ALLOC_N(disk->driverType, (tmp - disk->src) + 1) < 0)
+ goto no_memory;
+ strncpy(disk->driverType, disk->src, (tmp - disk->src));
+ disk->driverType[tmp - disk->src] = '\0';
+
+ /* Strip the prefix we found off the source file name */
+ memmove(disk->src, disk->src+(tmp-disk->src)+1,
+ strlen(disk->src)-(tmp-disk->src));
+ }
}
+ /* No source, or driver name, so fix to phy: */
+ if (!disk->driverName &&
+ !(disk->driverName = strdup("phy")))
+ goto no_memory;
+
+
/* phy: type indicates a block device */
disk->type = STREQ(disk->driverName, "phy") ?
VIR_DOMAIN_DISK_TYPE_BLOCK : VIR_DOMAIN_DISK_TYPE_FILE;
Index: src/domain_conf.c
===================================================================
RCS file: /data/cvs/libvirt/src/domain_conf.c,v
retrieving revision 1.39
diff -u -p -r1.39 domain_conf.c
--- src/domain_conf.c 21 Nov 2008 11:42:51 -0000 1.39
+++ src/domain_conf.c 27 Nov 2008 12:15:06 -0000
@@ -546,6 +546,14 @@ virDomainDiskDefParseXML(virConnectPtr c
source = virXMLPropString(cur, "file");
else
source = virXMLPropString(cur, "dev");
+
+ /* People sometimes pass a bogus '' source path
+ when they mean to omit the source element
+ completely. eg CDROM without media. This is
+ just a little compatability check to help
+ those broken apps */
+ if (source && STREQ(source, ""))
+ VIR_FREE(source);
} else if ((target == NULL) &&
(xmlStrEqual(cur->name, BAD_CAST "target"))) {
target = virXMLPropString(cur, "dev");
Index: tests/xmconfigtest.c
===================================================================
RCS file: /data/cvs/libvirt/tests/xmconfigtest.c,v
retrieving revision 1.24
diff -u -p -r1.24 xmconfigtest.c
--- tests/xmconfigtest.c 24 Nov 2008 19:23:39 -0000 1.24
+++ tests/xmconfigtest.c 27 Nov 2008 12:15:13 -0000
@@ -229,6 +229,7 @@ mymain(int argc, char **argv)
DO_TEST("fullvirt-sound", 2);
DO_TEST("escape-paths", 2);
+ DO_TEST("no-source-cdrom", 2);
virCapabilitiesFree(caps);
Index: tests/xmconfigdata/test-no-source-cdrom.cfg
===================================================================
RCS file: tests/xmconfigdata/test-no-source-cdrom.cfg
diff -N tests/xmconfigdata/test-no-source-cdrom.cfg
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/xmconfigdata/test-no-source-cdrom.cfg 27 Nov 2008 12:15:27 -0000
@@ -0,0 +1,23 @@
+name = "test"
+uuid = "cc2315e7-d26a-307a-438c-6d188ec4c09c"
+maxmem = 382
+memory = 350
+vcpus = 1
+builder = "hvm"
+kernel = "/usr/lib/xen/boot/hvmloader"
+boot = "c"
+pae = 1
+acpi = 1
+apic = 1
+localtime = 0
+on_poweroff = "destroy"
+on_reboot = "destroy"
+on_crash = "destroy"
+device_model = "/usr/lib/xen/bin/qemu-dm"
+sdl = 0
+vnc = 1
+vncunused = 1
+disk = [ "phy:/dev/sda8,hda,w", ",hdc:cdrom,r" ]
+vif = [ "mac=00:16:3e:0a:7b:39,bridge=xenbr0,type=ioemu" ]
+parallel = "none"
+serial = "pty"
Index: tests/xmconfigdata/test-no-source-cdrom.xml
===================================================================
RCS file: tests/xmconfigdata/test-no-source-cdrom.xml
diff -N tests/xmconfigdata/test-no-source-cdrom.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/xmconfigdata/test-no-source-cdrom.xml 27 Nov 2008 12:15:27 -0000
@@ -0,0 +1,46 @@
+<domain type='xen'>
+ <name>test</name>
+ <uuid>cc2315e7-d26a-307a-438c-6d188ec4c09c</uuid>
+ <memory>391168</memory>
+ <currentMemory>358400</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686' machine='xenfv'>hvm</type>
+ <loader>/usr/lib/xen/boot/hvmloader</loader>
+ <boot dev='hd'/>
+ </os>
+ <features>
+ <acpi/>
+ <apic/>
+ <pae/>
+ </features>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>destroy</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/lib/xen/bin/qemu-dm</emulator>
+ <disk type='block' device='disk'>
+ <driver name='phy'/>
+ <source dev='/dev/sda8'/>
+ <target dev='hda' bus='ide'/>
+ </disk>
+ <disk type='block' device='cdrom'>
+ <driver name='phy'/>
+ <target dev='hdc' bus='ide'/>
+ <readonly/>
+ </disk>
+ <interface type='bridge'>
+ <mac address='00:16:3e:0a:7b:39'/>
+ <source bridge='xenbr0'/>
+ </interface>
+ <serial type='pty'>
+ <target port='0'/>
+ </serial>
+ <console type='pty'>
+ <target port='0'/>
+ </console>
+ <input type='mouse' bus='ps2'/>
+ <graphics type='vnc' port='-1' autoport='yes'/>
+ </devices>
+</domain>
--
|: 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, 4 months
[libvirt] PATCH: Fix QEMU/UML use of libnuma
by Daniel P. Berrange
The 2.x series of numactl releases changed the ABI/API for certain
libnuma.so functions we use. Fortunately it turns out that they provide
back-compatability of both ABI and API with a combo of linker script
magic, and header file inline compat functions. So, all we need todo
is #define NUMA_VERSION1_COMPATIBILITY before include numa.h in our
code.
This new code did, however, expose a bug in our use of the existing
API. We were calculating size in bytes, instead of size in longs, so
were passing a buffer that was 8 times to large. Harmless, but the
new libnuma validates that the buffer is expected size. So this patch
also fixes us to pass & allocate correct buffer size.
Finally, also add a missing BuildRequire on numactl-devel, and fixes
the libvirtd automake build dependancy
Daniel
Index: libvirt.spec.in
===================================================================
RCS file: /data/cvs/libvirt/libvirt.spec.in,v
retrieving revision 1.103
diff -u -p -r1.103 libvirt.spec.in
--- libvirt.spec.in 26 Nov 2008 14:46:49 -0000 1.103
+++ libvirt.spec.in 27 Nov 2008 13:20:24 -0000
@@ -124,6 +124,8 @@ BuildRequires: lvm2
BuildRequires: iscsi-initiator-utils
# For disk driver
BuildRequires: parted-devel
+# For QEMU/LXC numa info
+BuildRequires: numactl-devel
Obsoletes: libvir
# Fedora build root suckage
Index: qemud/Makefile.am
===================================================================
RCS file: /data/cvs/libvirt/qemud/Makefile.am,v
retrieving revision 1.61
diff -u -p -r1.61 Makefile.am
--- qemud/Makefile.am 21 Nov 2008 12:27:11 -0000 1.61
+++ qemud/Makefile.am 27 Nov 2008 13:20:24 -0000
@@ -87,7 +87,6 @@ libvirtd_LDFLAGS = \
$(COVERAGE_LDFLAGS) \
$(POLKIT_LIBS)
-libvirtd_DEPENDENCIES = ../src/libvirt.la
libvirtd_LDADD = \
../gnulib/lib/libgnu.la
@@ -129,6 +128,9 @@ libvirtd_CFLAGS += $(AVAHI_CFLAGS)
libvirtd_LDADD += $(AVAHI_LIBS)
endif
+libvirtd_DEPENDENCIES = $(libvirtd_LDADD)
+
+
default_xml_dest = libvirt/qemu/networks/default.xml
install-data-local: install-init install-data-sasl install-data-polkit
mkdir -p $(DESTDIR)$(sysconfdir)/libvirt/qemu/networks/autostart
Index: src/qemu_conf.c
===================================================================
RCS file: /data/cvs/libvirt/src/qemu_conf.c,v
retrieving revision 1.108
diff -u -p -r1.108 qemu_conf.c
--- src/qemu_conf.c 19 Nov 2008 16:58:23 -0000 1.108
+++ src/qemu_conf.c 27 Nov 2008 13:20:24 -0000
@@ -37,6 +37,7 @@
#include <sys/utsname.h>
#if HAVE_NUMACTL
+#define NUMA_VERSION1_COMPATIBILITY 1
#include <numa.h>
#endif
@@ -300,11 +301,11 @@ qemudCapsInitGuest(virCapsPtr caps,
#if HAVE_NUMACTL
#define MAX_CPUS 4096
#define MAX_CPUS_MASK_SIZE (sizeof(unsigned long))
-#define MAX_CPUS_MASK_LEN (MAX_CPUS / MAX_CPUS_MASK_SIZE)
-#define MAX_CPUS_MASK_BYTES (MAX_CPUS / 8)
+#define MAX_CPUS_MASK_BITS (MAX_CPUS_MASK_SIZE * 8)
+#define MAX_CPUS_MASK_LEN (MAX_CPUS / (MAX_CPUS_MASK_BITS))
#define MASK_CPU_ISSET(mask, cpu) \
- (((mask)[((cpu) / MAX_CPUS_MASK_SIZE)] >> ((cpu) % MAX_CPUS_MASK_SIZE)) & 1)
+ (((mask)[((cpu) / MAX_CPUS_MASK_BITS)] >> ((cpu) % MAX_CPUS_MASK_BITS)) & 1)
static int
qemudCapsInitNUMA(virCapsPtr caps)
@@ -322,7 +323,8 @@ qemudCapsInitNUMA(virCapsPtr caps)
goto cleanup;
for (n = 0 ; n <= numa_max_node() ; n++) {
- if (numa_node_to_cpus(n, mask, MAX_CPUS_MASK_BYTES) < 0)
+
+ if (numa_node_to_cpus(n, mask, MAX_CPUS_MASK_LEN) < 0)
goto cleanup;
for (ncpus = 0, i = 0 ; i < MAX_CPUS ; i++)
Index: src/qemu_driver.c
===================================================================
RCS file: /data/cvs/libvirt/src/qemu_driver.c,v
retrieving revision 1.160
diff -u -p -r1.160 qemu_driver.c
--- src/qemu_driver.c 21 Nov 2008 12:16:08 -0000 1.160
+++ src/qemu_driver.c 27 Nov 2008 13:20:25 -0000
@@ -45,6 +45,7 @@
#include <sys/ioctl.h>
#if HAVE_NUMACTL
+#define NUMA_VERSION1_COMPATIBILITY 1
#include <numa.h>
#endif
Index: src/uml_conf.c
===================================================================
RCS file: /data/cvs/libvirt/src/uml_conf.c,v
retrieving revision 1.1
diff -u -p -r1.1 uml_conf.c
--- src/uml_conf.c 19 Nov 2008 16:58:23 -0000 1.1
+++ src/uml_conf.c 27 Nov 2008 13:20:25 -0000
@@ -37,6 +37,7 @@
#include <sys/utsname.h>
#if HAVE_NUMACTL
+#define NUMA_VERSION1_COMPATIBILITY 1
#include <numa.h>
#endif
@@ -56,11 +57,11 @@
#if HAVE_NUMACTL
#define MAX_CPUS 4096
#define MAX_CPUS_MASK_SIZE (sizeof(unsigned long))
-#define MAX_CPUS_MASK_LEN (MAX_CPUS / MAX_CPUS_MASK_SIZE)
-#define MAX_CPUS_MASK_BYTES (MAX_CPUS / 8)
+#define MAX_CPUS_MASK_BITS (MAX_CPUS_MASK_SIZE * 8)
+#define MAX_CPUS_MASK_LEN (MAX_CPUS / (MAX_CPUS_MASK_BITS))
#define MASK_CPU_ISSET(mask, cpu) \
- (((mask)[((cpu) / MAX_CPUS_MASK_SIZE)] >> ((cpu) % MAX_CPUS_MASK_SIZE)) & 1)
+ (((mask)[((cpu) / MAX_CPUS_MASK_BITS)] >> ((cpu) % MAX_CPUS_MASK_BITS)) & 1)
static int
umlCapsInitNUMA(virCapsPtr caps)
@@ -78,7 +79,8 @@ umlCapsInitNUMA(virCapsPtr caps)
goto cleanup;
for (n = 0 ; n <= numa_max_node() ; n++) {
- if (numa_node_to_cpus(n, mask, MAX_CPUS_MASK_BYTES) < 0)
+
+ if (numa_node_to_cpus(n, mask, MAX_CPUS_MASK_LEN) < 0)
goto cleanup;
for (ncpus = 0, i = 0 ; i < MAX_CPUS ; i++)
Index: src/uml_driver.c
===================================================================
RCS file: /data/cvs/libvirt/src/uml_driver.c,v
retrieving revision 1.2
diff -u -p -r1.2 uml_driver.c
--- src/uml_driver.c 21 Nov 2008 10:06:28 -0000 1.2
+++ src/uml_driver.c 27 Nov 2008 13:20:25 -0000
@@ -46,6 +46,7 @@
#include <sys/inotify.h>
#if HAVE_NUMACTL
+#define NUMA_VERSION1_COMPATIBILITY 1
#include <numa.h>
#endif
--
|: 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, 4 months
[libvirt] Hide fully-virtualized network devices to domU with PV drivers
by Iain Watson
Hello,
I have a problem with libvirt which I hope someone on this list might
be able to help with.
I have many DomU images which all have PV drivers loaded for network.
I want to start these DomU guests with only the PV network device
being visible from within the DomU.
In testing I have been able to create the required system with the
'xm' command. The important part of the network line is "type=none".
The complete line looks like:
vif = [ "mac=00:16:3e:00:a5:57,bridge=eth0,script=vif-bridge,type=none" ]
With libvirt I have tried adding "<model type='none'/>" into the
interface section but this errors with "qemu: Unsupported NIC: none"
so I'm obviously missing something obvious. The complete interface
section looks like:
<interface type='bridge'>
<mac address='00:16:3e:00:a5:57'/>
<source bridge='eth0'/>
<target dev='vif9.0'/>
<model type='none'/>
</interface>
I have been able to achieve the required configuration if I completely
omit an 'interface' section and once the DomU has booted I use virsh
to add an interface to the domain. Unfortunately if I then reboot the
DomU the guest comes back up with two network interfaces visible to it
and the qemu-dm line has added a "-net ...,model=rtl8139" option.
Having hunted around I am yet to find a way to configure a domU in
libvirt so the networking available to the guest is the way I require.
As I can do this with xm, I'm hoping someone on this list can point me
in the right direction to also do this with libvirt.
Thanks in advance,
Iain Watson
16 years, 4 months
[libvirt] [PATCH 1/2]: Give /dev/disk/by-{id, path} a chance to exist
by Chris Lalancette
This patch is the same idea as my previous patch for giving
/dev/disk/by-{id,path} a chance to exist. Currently libvirt can race with udev
creation of /dev/disk/by-{id,path}, so if we fail to open the directory, retry
up to 5 seconds. This is only likely to happen on hosts that are:
1) diskless (so /dev/disk/by-{id,path} doesn't exist already), and
2) slow, and/or heavily loaded (meaning that udev can take some time to create
the /dev nodes).
Based on the feedback from Dan and Jim, I updated the patch to look more like
what is elsewhere in libvirt.
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
Index: src/storage_backend.c
===================================================================
RCS file: /data/cvs/libvirt/src/storage_backend.c,v
retrieving revision 1.29
diff -u -r1.29 storage_backend.c
--- a/src/storage_backend.c 17 Nov 2008 11:19:33 -0000 1.29
+++ b/src/storage_backend.c 26 Nov 2008 12:09:36 -0000
@@ -291,6 +291,7 @@
DIR *dh;
struct dirent *dent;
char *stablepath;
+ int opentries = 0;
/* Short circuit if pool has no target, or if its /dev */
if (pool->def->target.path == NULL ||
@@ -304,12 +305,17 @@
if (!STRPREFIX(pool->def->target.path, "/dev"))
goto ret_strdup;
- /* The pool is pointing somewhere like /dev/disk/by-path
- * or /dev/disk/by-id, so we need to check all symlinks in
- * the target directory and figure out which one points
- * to this device node
+ /* We loop here because /dev/disk/by-{id,path} may not have existed
+ * before we started this operation, so we have to give it some time to
+ * get created.
*/
+ reopen:
if ((dh = opendir(pool->def->target.path)) == NULL) {
+ opentries++;
+ if (errno == ENOENT && opentries < 50) {
+ usleep(100 * 1000);
+ goto reopen;
+ }
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
_("cannot read dir %s: %s"),
pool->def->target.path,
@@ -317,6 +323,11 @@
return NULL;
}
+ /* The pool is pointing somewhere like /dev/disk/by-path
+ * or /dev/disk/by-id, so we need to check all symlinks in
+ * the target directory and figure out which one points
+ * to this device node
+ */
while ((dent = readdir(dh)) != NULL) {
if (dent->d_name[0] == '.')
continue;
16 years, 4 months
[libvirt] PATCH: Allow automatic driver probe for remote TCP connections
by Daniel P. Berrange
When connecting to a local libvirt you can let it automatically probe
the hypervisor URI if you don't know it ahead of time. This doesn't
work with remote URIs because you need to have something to put in
the URI scheme before the hostname
qemu+ssh://somehost/system
xen+tcp://somehost/system
This is then translated into the URI
qemu:///system
xen:///
It occurred to me that we can trivially enable probing with all existing
libvirtd daemon releases, simply by fixing the client side. All we need
todo is invent a new generic URI scheme, and convert that to empty string
This patch adds a 'remote' URI scheme, usable like this
remote+ssh://somehost/
remote+tcp://somehost/
remote://somehost/
remote+tls://somehost/
remote+ext://somehost/
In all these styles, the URI passed to the remote daemon is "", causing
it to probe.
As a demonstration, here's an example using virsh and two hosts I have,
one running Xen, the other QEMU
See it automatically choosing QEMU....
$ virsh --connect remote+ssh://root@lettuce/ version
Compiled against library: libvir 0.5.0
Using library: libvir 0.5.0
Running hypervisor: QEMU 0.9.1
And choosing Xen....
$ virsh --connect remote+ssh://root@pumpkin/ version
Compiled against library: libvir 0.5.0
Using library: libvir 0.5.0
Running hypervisor: Xen 3.1.0
This finally makes the Avahi broadcasts useful - they only include
info on the hostname + data transport (SSH, TCP, TLS), not the HV
type. So letting us use auto-probing remotely is the missing link.
NB. we've got a small problem with the virGetVersion() API - it does not
take a connection URI - just a hypervisor type. It then directly checks
the statically declared 'version' field in the virDriverPtr struct.
This no longer works now that some drivers are linked directly into the
libvirt daemon.
I'm thinking that perhaps we can just change the virGetVersion() apis
so that instead of looking in virDriverPtr struct, we just include the
version numbers directly in virGetVersion as a static const lookup
table. Meanwhile, this patch also includes a change to virsh to stop
it calling virGetVersion(), though this hunk instead intended to apply
to CVS.
Daniel
Index: remote_internal.c
===================================================================
RCS file: /data/cvs/libvirt/src/remote_internal.c,v
retrieving revision 1.108
diff -u -p -r1.108 remote_internal.c
--- remote_internal.c 21 Nov 2008 12:31:04 -0000 1.108
+++ remote_internal.c 26 Nov 2008 21:58:47 -0000
@@ -430,28 +430,40 @@ doRemoteOpen (virConnectPtr conn,
/* Construct the original name. */
if (!name) {
- xmlURI tmpuri = {
- .scheme = conn->uri->scheme,
+ if (STREQ(conn->uri->scheme, "remote") ||
+ STRPREFIX(conn->uri->scheme, "remote+")) {
+ /* Allow remote serve to probe */
+ name = strdup("");
+ } else {
+ xmlURI tmpuri = {
+ .scheme = conn->uri->scheme,
#ifdef HAVE_XMLURI_QUERY_RAW
- .query_raw = qparam_get_query (vars),
+ .query_raw = qparam_get_query (vars),
#else
- .query = qparam_get_query (vars),
+ .query = qparam_get_query (vars),
#endif
- .path = conn->uri->path,
- .fragment = conn->uri->fragment,
- };
-
- /* Evil, blank out transport scheme temporarily */
- if (transport_str) {
- assert (transport_str[-1] == '+');
- transport_str[-1] = '\0';
- }
+ .path = conn->uri->path,
+ .fragment = conn->uri->fragment,
+ };
+
+ /* Evil, blank out transport scheme temporarily */
+ if (transport_str) {
+ assert (transport_str[-1] == '+');
+ transport_str[-1] = '\0';
+ }
+
+ name = (char *) xmlSaveUri (&tmpuri);
- name = (char *) xmlSaveUri (&tmpuri);
+#ifdef HAVE_XMLURI_QUERY_RAW
+ VIR_FREE(tmpuri.query_raw);
+#else
+ VIR_FREE(tmpuri.query);
+#endif
- /* Restore transport scheme */
- if (transport_str)
- transport_str[-1] = '+';
+ /* Restore transport scheme */
+ if (transport_str)
+ transport_str[-1] = '+';
+ }
}
free_qparam_set (vars);
Index: virsh.c
===================================================================
RCS file: /data/cvs/libvirt/src/virsh.c,v
retrieving revision 1.175
diff -u -p -r1.175 virsh.c
--- virsh.c 24 Nov 2008 07:13:30 -0000 1.175
+++ virsh.c 26 Nov 2008 21:58:51 -0000
@@ -4357,7 +4357,6 @@ cmdVersion(vshControl *ctl, const vshCmd
const char *hvType;
unsigned long libVersion;
unsigned long includeVersion;
- unsigned long apiVersion;
int ret;
unsigned int major;
unsigned int minor;
@@ -4380,7 +4379,8 @@ cmdVersion(vshControl *ctl, const vshCmd
vshPrint(ctl, _("Compiled against library: libvir %d.%d.%d\n"),
major, minor, rel);
- ret = virGetVersion(&libVersion, hvType, &apiVersion);
+
+ ret = virGetVersion(&libVersion, NULL, NULL);
if (ret < 0) {
vshError(ctl, FALSE, "%s", _("failed to get the library version"));
return FALSE;
@@ -4392,13 +4392,6 @@ cmdVersion(vshControl *ctl, const vshCmd
vshPrint(ctl, _("Using library: libvir %d.%d.%d\n"),
major, minor, rel);
- major = apiVersion / 1000000;
- apiVersion %= 1000000;
- minor = apiVersion / 1000;
- rel = apiVersion % 1000;
- vshPrint(ctl, _("Using API: %s %d.%d.%d\n"), hvType,
- major, minor, rel);
-
ret = virConnectGetVersion(ctl->conn, &hvVersion);
if (ret < 0) {
vshError(ctl, FALSE, "%s", _("failed to get the hypervisor version"));
--
|: 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, 4 months
[libvirt] [PATCH 0/2]: Make storage_backend device scanning more reliable
by Chris Lalancette
All,
This is a 2 part patch series to make libvirt backend device scanning more
reliable. In particular, this is important for things that can create/destroy
udev /dev nodes, since at present we can race with the udev creation. Note that
this takes over the previous patch that I posted to retry /dev/disk/by-{id,path}
scanning.
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
16 years, 4 months
[libvirt] make not invoking rpcgen remote_protocol.x
by Kenneth Nagin
I am attempting to add some new libvirt functions that I intend to submit
for your approval.
I have made changes to remote_protocol.x. Initially it generated the
expected files.
However, after making a few changes the make no causes it to generate
files.
Manually invoke rpcgen -c remote_protocol.x > remote_protocol.c seems
to get around the compile problem. But now I'm getting a "Remote error :
marshaling args"
I 'm think there is a problem in the make.
Kenneth Nagin
16 years, 4 months
[libvirt] libvirt_low_level_storage_api
by shahar@compal1.qumranet.com
Hi All, here is an initial version of the operations required for SolidICE and the proposed high level interface.
I would like to discuss how to map it to libvirt calls and what libvirt calls are missing.
Thanks,
Shahar Frank
HostLevel
---------
enumarateLuns():
return:
returns all luns visible by the host.
In case multipathing is enabled then only the multipath device should be in the return list.
enumerateISCSILuns(target):
params:
target - ISCSI target
Description:
enumerate all ISCSI luns on a specific target
return:
list of
getBlockInfo(name or UUID):
return:
at least uuid & size
enumerateVGs():
return:
VG UUID list
open issues - should we assume ISCSI auto connect or FC login?
StoragePool level
-----------------
createVolumeGroup(name, devices):
params:
name = name
devices - a list of UUIDs
description:
Should create a volume group out of the UUID list
In case multipathing is enabled then only the multipath device should be used
In case it is not a PV yet then a PV is to be created.
Return:
Uuid of the VG
removeVolumeGroup(VG):
params:
VG - uuid of the Volume group
Description:
Remove all remains for the VolumeGroup (LVs, PVs ...)
Return:
Sucsess/failure
mountNFS(server, remotePath, localPath, params)
params:
server - the NFS server name or IP
temotePath - remote server export path
localPath - local path to mount on
params - nfs mount params
description:
mounts the remote export onto the local path using the mount params
return:
success/failure
unmount(localPath, forceFlag)
params:
localPath - the local path to unmount
forceFlag - a flag indicating whether to force unmount
description:
unmounts local path (trivial)
return:
success/failure
Open issues:
1. NFS configuration persistency?
2. What happens in case the libvirt is restarted should it be reconfigured?
VolumeGroup level
-----------------
listPV(VG):
params:
VG - Volume group UUID
Description:
Lists all PV in a specific volume group
Return:
A list of PV UUIDs
infoPV(VG, PV)
params:
VG - Volume group UUID
PV - Physical volume UUID
description:
trivial
return:
returns the PV information (at least size & path)
extendVolumeGroup(VG, devices):
params:
VG - Volume Group UUID
devices - a list of UUIDs
description:
This function adds Phisical Volume to the VolumeGroup.
Each UUID device is checked, In case multipathing is enabled
then only the multipath device should be used (PV create in case
it's not) and added to the volume group
return:
success/fauilure
removePV(VG, PV):
params:
VG - Volume Group UUID
PV - Physical volume's UUID to be removed
description:
removes the physical volume
return:
success failure
LV operations
--------------
listLVs(VG):
params:
VG - Volume Group UUID
description:
trivial
return:
list of all LV UUIDs
infoLV(VG, LV):
params:
VG - Volume Group UUID
LV - Logical Volume UUID
description:
trivial
return:
returns LV information (at least size and path)
createLV(VG, LvName, size):
params:
VG - Volume Group UUID
LvName - name of the logical volume
Size - size of logical volume
description:
creates a logical volume with name LvName and the requested size
return:
LV UUID
extendLV(VG, LV, size):
params:
VG - Volume Group UUID
LV - Logical Volume UUID
description:
extends LV with additional size
return:
success/failure
removeLV(VG,LV):
params:
VG - Volume Group UUID
LV - Logical Volume UUID
description:
return:
snapshotLV(VG, LV, size):
params:
VG - Volume Group UUID
LV - Logical Volume UUID
size - Initial size of snapshot volume
description:
creeates a snapshot of LV
return:
UUID of snapshot
16 years, 4 months
[libvirt] serial console runs out of buffer and console messages soft lock the CPU
by Bryan McLellan
I recently started configuring guests to use both a serial console and
a graphics element. One of the nodes with this configuration kept
locking up after running for some time. Trying to access the guest
through virt-manager would leave virt-viewer hung at the connecting to
screen. The guest would not respond to any network traffic including
icmp. The user would destroy the domain and restart it to recover.
Eventually the problem came to me and I found that immediately upon
running 'virsh console domain' the guest would recover. The console
contained:
BUG: soft lockup - CPU#0 stuck for 94393s! [postgresql-8.3:4975]
I discovered a bug in a puppet recipe caused postgres to reload
regularly, printing a message to the console each time. Running puppet
in a loop to continue producing these messages to the console caused
another lockup that was recoverable by accessing the serial console in
the same manner. I have since fixed that recipe, but I'm uncomfortable
about the possibility of this happening again.
Is there a way to configure libvirt to cache the serial console on the
host so the buffer on the guest does not fill up when you aren't
connected to the console, or should I disable the serial console?
Bryan
https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/301897
16 years, 4 months