[Libvir] updated: Support Sun's Compiler
by Mark Johnson
I've cleaned up the patch from the previous comments...
Sorry I'm off the original thread, switched over to mutt
and am waiting for fetchmail to catch up with gmail..
tested on today's CVS bits on a FC7 dom0
(LD_PRELOAD=src/.libs/libvirt.so src/.libs/virsh)
Thanks,
MRJ
---
fixes to compile with Sun's CC
diff --git a/src/internal.h b/src/internal.h
--- a/src/internal.h
+++ b/src/internal.h
@@ -25,11 +25,6 @@ extern "C" {
#define _(str) dgettext(GETTEXT_PACKAGE, (str))
#define N_(str) dgettext(GETTEXT_PACKAGE, (str))
#define gettext_noop(str) (str)
-
-#ifdef __GNUC__
-#ifdef HAVE_ANSIDECL_H
-#include <ansidecl.h>
-#endif
/* String equality tests, suggested by Jim Meyering. */
#define STREQ(a,b) (strcmp((a),(b)) == 0)
@@ -39,6 +34,15 @@ extern "C" {
#define STREQLEN(a,b,n) (strncmp((a),(b),(n)) == 0)
#define STRNEQLEN(a,b,n) (strncmp((a),(b),(n)) != 0)
+#ifndef __GNUC__
+#define __FUNCTION__ __func__
+#endif
+
+#ifdef __GNUC__
+#ifdef HAVE_ANSIDECL_H
+#include <ansidecl.h>
+#endif
+
/**
* ATTRIBUTE_UNUSED:
*
@@ -61,7 +65,7 @@ extern "C" {
#else
#define ATTRIBUTE_UNUSED
#define ATTRIBUTE_FORMAT(...)
-#endif
+#endif /* __GNUC__ */
/**
* TODO:
diff --git a/src/sexpr.c b/src/sexpr.c
--- a/src/sexpr.c
+++ b/src/sexpr.c
@@ -80,11 +80,11 @@ sexpr_free(struct sexpr *sexpr)
switch (sexpr->kind) {
case SEXPR_CONS:
- sexpr_free(sexpr->car);
- sexpr_free(sexpr->cdr);
+ sexpr_free(sexpr->u.s.car);
+ sexpr_free(sexpr->u.s.cdr);
break;
case SEXPR_VALUE:
- free(sexpr->value);
+ free(sexpr->u.value);
break;
case SEXPR_NIL:
break;
@@ -127,12 +127,12 @@ sexpr_string(const char *str, ssize_t le
return ret;
ret->kind = SEXPR_VALUE;
if (len > 0) {
- ret->value = strndup(str, len);
+ ret->u.value = strndup(str, len);
} else {
- ret->value = strdup(str);
- }
-
- if (ret->value == NULL) {
+ ret->u.value = strdup(str);
+ }
+
+ if (ret->u.value == NULL) {
return NULL;
}
@@ -157,8 +157,8 @@ sexpr_cons(struct sexpr *car, struct sex
if (ret == NULL)
return ret;
ret->kind = SEXPR_CONS;
- ret->car = car;
- ret->cdr = cdr;
+ ret->u.s.car = car;
+ ret->u.s.cdr = cdr;
return ret;
}
@@ -174,12 +174,12 @@ append(struct sexpr *lst, struct sexpr *
append(struct sexpr *lst, struct sexpr *value)
{
while (lst->kind != SEXPR_NIL) {
- lst = lst->cdr;
+ lst = lst->u.s.cdr;
}
lst->kind = SEXPR_CONS;
- lst->car = value;
- lst->cdr = sexpr_nil();
+ lst->u.s.car = value;
+ lst->u.s.cdr = sexpr_nil();
}
/**
@@ -228,18 +228,18 @@ sexpr2string(struct sexpr * sexpr, char
if (tmp == 0)
goto error;
ret += tmp;
- tmp = sexpr2string(sexpr->car, buffer + ret, n_buffer - ret);
+ tmp = sexpr2string(sexpr->u.s.car, buffer + ret, n_buffer - ret);
if (tmp == 0)
goto error;
ret += tmp;
- while (sexpr->cdr->kind != SEXPR_NIL) {
- sexpr = sexpr->cdr;
+ while (sexpr->u.s.cdr->kind != SEXPR_NIL) {
+ sexpr = sexpr->u.s.cdr;
tmp = snprintf(buffer + ret, n_buffer - ret, " ");
if (tmp == 0)
goto error;
ret += tmp;
tmp =
- sexpr2string(sexpr->car, buffer + ret, n_buffer - ret);
+ sexpr2string(sexpr->u.s.car, buffer + ret, n_buffer - ret);
if (tmp == 0)
goto error;
ret += tmp;
@@ -250,12 +250,12 @@ sexpr2string(struct sexpr * sexpr, char
ret += tmp;
break;
case SEXPR_VALUE:
- if (strchr(sexpr->value, ' '))
+ if (strchr(sexpr->u.value, ' '))
tmp = snprintf(buffer + ret, n_buffer - ret, "'%s'",
- sexpr->value);
+ sexpr->u.value);
else
tmp = snprintf(buffer + ret, n_buffer - ret, "%s",
- sexpr->value);
+ sexpr->u.value);
if (tmp == 0)
goto error;
ret += tmp;
@@ -346,8 +346,8 @@ _string2sexpr(const char *buffer, size_t
ptr++;
}
- ret->value = strndup(start, ptr - start);
- if (ret->value == NULL) {
+ ret->u.value = strndup(start, ptr - start);
+ if (ret->u.value == NULL) {
virSexprError(VIR_ERR_NO_MEMORY,
_("failed to copy a string"));
}
@@ -361,15 +361,15 @@ _string2sexpr(const char *buffer, size_t
ptr++;
}
- ret->value = strndup(start, ptr - start);
- if (ret->value == NULL) {
+ ret->u.value = strndup(start, ptr - start);
+ if (ret->u.value == NULL) {
virSexprError(VIR_ERR_NO_MEMORY,
_("failed to copy a string"));
}
}
ret->kind = SEXPR_VALUE;
- if (ret->value == NULL)
+ if (ret->u.value == NULL)
goto error;
}
@@ -426,11 +426,11 @@ sexpr_lookup(struct sexpr *sexpr, const
ptr = buffer;
token = strsep(&ptr, "/");
- if (sexpr->kind != SEXPR_CONS || sexpr->car->kind != SEXPR_VALUE) {
- return NULL;
- }
-
- if (strcmp(sexpr->car->value, token) != 0) {
+ if (sexpr->kind != SEXPR_CONS || sexpr->u.s.car->kind != SEXPR_VALUE) {
+ return NULL;
+ }
+
+ if (strcmp(sexpr->u.s.car->u.value, token) != 0) {
return NULL;
}
@@ -440,16 +440,16 @@ sexpr_lookup(struct sexpr *sexpr, const
if (token == NULL)
continue;
- sexpr = sexpr->cdr;
- for (i = sexpr; i->kind != SEXPR_NIL; i = i->cdr) {
+ sexpr = sexpr->u.s.cdr;
+ for (i = sexpr; i->kind != SEXPR_NIL; i = i->u.s.cdr) {
if (i->kind != SEXPR_CONS ||
- i->car->kind != SEXPR_CONS ||
- i->car->car->kind != SEXPR_VALUE) {
+ i->u.s.car->kind != SEXPR_CONS ||
+ i->u.s.car->u.s.car->kind != SEXPR_VALUE) {
continue;
}
- if (strcmp(i->car->car->value, token) == 0) {
- sexpr = i->car;
+ if (strcmp(i->u.s.car->u.s.car->u.value, token) == 0) {
+ sexpr = i->u.s.car;
break;
}
}
@@ -463,10 +463,10 @@ sexpr_lookup(struct sexpr *sexpr, const
return NULL;
}
- if (sexpr->kind != SEXPR_CONS || sexpr->cdr->kind != SEXPR_CONS)
- return NULL;
-
- return sexpr->cdr;
+ if (sexpr->kind != SEXPR_CONS || sexpr->u.s.cdr->kind != SEXPR_CONS)
+ return NULL;
+
+ return sexpr->u.s.cdr;
}
/**
@@ -484,7 +484,7 @@ sexpr_node(struct sexpr *sexpr, const ch
{
struct sexpr *n = sexpr_lookup(sexpr, node);
- return (n && n->car->kind == SEXPR_VALUE) ? n->car->value : NULL;
+ return (n && n->u.s.car->kind == SEXPR_VALUE) ? n->u.s.car->u.value : NULL;
}
/**
diff --git a/src/sexpr.h b/src/sexpr.h
--- a/src/sexpr.h
+++ b/src/sexpr.h
@@ -29,9 +29,9 @@ struct sexpr {
struct {
struct sexpr *car;
struct sexpr *cdr;
- };
+ } s;
char *value;
- };
+ } u;
};
/* conversion to/from strings */
diff --git a/src/virsh.c b/src/virsh.c
--- a/src/virsh.c
+++ b/src/virsh.c
@@ -4295,9 +4295,9 @@ vshDomainStateToString(int state)
case VIR_DOMAIN_CRASHED:
return gettext_noop("crashed");
default:
- return gettext_noop("no state"); /* = dom0 state */
- }
- return NULL;
+ ;/*FALLTHROUGH*/
+ }
+ return gettext_noop("no state"); /* = dom0 state */
}
static const char *
@@ -4311,9 +4311,9 @@ vshDomainVcpuStateToString(int state)
case VIR_VCPU_RUNNING:
return gettext_noop("running");
default:
- return gettext_noop("no state");
- }
- return NULL;
+ ;/*FALLTHROUGH*/
+ }
+ return gettext_noop("no state");
}
static int
@@ -4825,7 +4825,7 @@ vshParseArgv(vshControl * ctl, int argc,
}
last = argv[i];
}
- end = end ? : argc;
+ end = end ? end : argc;
/* standard (non-command) options */
while ((arg = getopt_long(end, argv, "d:hqtc:vrl:", opt, &idx)) != -1) {
diff --git a/src/xend_internal.c b/src/xend_internal.c
--- a/src/xend_internal.c
+++ b/src/xend_internal.c
@@ -189,9 +189,9 @@ virXendErrorInt(virConnectPtr conn, virE
#define foreach(iterator, start) \
- for (_for_i = (start), *iterator = (start)->car; \
+ for (_for_i = (start), *iterator = (start)->u.s.car; \
_for_i->kind == SEXPR_CONS; \
- _for_i = _for_i->cdr, iterator = _for_i->car)
+ _for_i = _for_i->u.s.cdr, iterator = _for_i->u.s.car)
#define foreach_node(iterator, start, path) \
foreach(iterator, start) \
@@ -661,23 +661,22 @@ xend_node_op(virConnectPtr xend, const c
* Returns 0 in case of success, -1 in case of failure.
*/
static int
-xend_op_ext(virConnectPtr xend, const char *name, char *error,
- size_t n_error, const char *key, ...)
+xend_op(virConnectPtr xend, const char *name, const char *key, ...)
{
char buffer[1024];
+ char error[1024];
va_list ap;
int ret;
snprintf(buffer, sizeof(buffer), "/xend/domain/%s", name);
va_start(ap, key);
- ret = xend_op_ext2(xend, buffer, error, n_error, key, ap);
+ ret = xend_op_ext2(xend, buffer, error, sizeof(error), key, ap);
va_end(ap);
return ret;
}
-#define xend_op(xend, name, key, ...) ({char error[1024]; xend_op_ext(xend, name, error, sizeof(error), key, __VA_ARGS__);})
#endif /* ! PROXY */
/**
@@ -960,11 +959,11 @@ xenDaemonListDomainsOld(virConnectPtr xe
if (root == NULL)
goto error;
- for (_for_i = root, node = root->car; _for_i->kind == SEXPR_CONS;
- _for_i = _for_i->cdr, node = _for_i->car) {
+ for (_for_i = root, node = root->u.s.car; _for_i->kind == SEXPR_CONS;
+ _for_i = _for_i->u.s.cdr, node = _for_i->u.s.car) {
if (node->kind != SEXPR_VALUE)
continue;
- extra += strlen(node->value) + 1;
+ extra += strlen(node->u.value) + 1;
count++;
}
@@ -976,13 +975,13 @@ xenDaemonListDomainsOld(virConnectPtr xe
ptr += sizeof(char *) * (count + 1);
i = 0;
- for (_for_i = root, node = root->car; _for_i->kind == SEXPR_CONS;
- _for_i = _for_i->cdr, node = _for_i->car) {
+ for (_for_i = root, node = root->u.s.car; _for_i->kind == SEXPR_CONS;
+ _for_i = _for_i->u.s.cdr, node = _for_i->u.s.car) {
if (node->kind != SEXPR_VALUE)
continue;
ret[i] = ptr;
- strcpy(ptr, node->value);
- ptr += strlen(node->value) + 1;
+ strcpy(ptr, node->u.value);
+ ptr += strlen(node->u.value) + 1;
i++;
}
@@ -1461,8 +1460,8 @@ xend_parse_sexp_desc(virConnectPtr conn,
if ((tmp != NULL) && (tmp[0] != 0))
virBufferVSprintf(&buf, " <emulator>%s</emulator>\n", tmp);
- for (cur = root; cur->kind == SEXPR_CONS; cur = cur->cdr) {
- node = cur->car;
+ for (cur = root; cur->kind == SEXPR_CONS; cur = cur->u.s.cdr) {
+ node = cur->u.s.car;
/* Normally disks are in a (device (vbd ...)) block
but blktap disks ended up in a differently named
(device (tap ....)) block.... */
@@ -1701,8 +1700,8 @@ xend_parse_sexp_desc(virConnectPtr conn,
/* in case of HVM we have devices emulation */
if (hvm) {
- for (cur = sexpr_lookup(root, "domain/image/hvm"); cur && cur->kind == SEXPR_CONS; cur = cur->cdr) {
- node = cur->car;
+ for (cur = sexpr_lookup(root, "domain/image/hvm"); cur && cur->kind == SEXPR_CONS; cur = cur->u.s.cdr) {
+ node = cur->u.s.car;
if (sexpr_lookup(node, "usbdevice")) {
tmp = sexpr_node(node, "usbdevice");
if (tmp && *tmp) {
@@ -2677,11 +2676,11 @@ xenDaemonListDomains(virConnectPtr conn,
ret = 0;
- for (_for_i = root, node = root->car; _for_i->kind == SEXPR_CONS;
- _for_i = _for_i->cdr, node = _for_i->car) {
+ for (_for_i = root, node = root->u.s.car; _for_i->kind == SEXPR_CONS;
+ _for_i = _for_i->u.s.cdr, node = _for_i->u.s.car) {
if (node->kind != SEXPR_VALUE)
continue;
- id = xenDaemonDomainLookupByName_ids(conn, node->value, NULL);
+ id = xenDaemonDomainLookupByName_ids(conn, node->u.value, NULL);
if (id >= 0)
ids[ret++] = (int) id;
if (ret >= maxids)
@@ -2715,8 +2714,8 @@ xenDaemonNumOfDomains(virConnectPtr conn
ret = 0;
- for (_for_i = root, node = root->car; _for_i->kind == SEXPR_CONS;
- _for_i = _for_i->cdr, node = _for_i->car) {
+ for (_for_i = root, node = root->u.s.car; _for_i->kind == SEXPR_CONS;
+ _for_i = _for_i->u.s.cdr, node = _for_i->u.s.car) {
if (node->kind != SEXPR_VALUE)
continue;
ret++;
@@ -2884,11 +2883,11 @@ xenDaemonDomainGetVcpus(virDomainPtr dom
memset(cpumaps, 0, maxinfo * maplen);
/* scan the sexprs from "(vcpu (number x)...)" and get parameter values */
- for (s = root; s->kind == SEXPR_CONS; s = s->cdr) {
- if ((s->car->kind == SEXPR_CONS) &&
- (s->car->car->kind == SEXPR_VALUE) &&
- !strcmp(s->car->car->value, "vcpu")) {
- t = s->car;
+ for (s = root; s->kind == SEXPR_CONS; s = s->u.s.cdr) {
+ if ((s->u.s.car->kind == SEXPR_CONS) &&
+ (s->u.s.car->u.s.car->kind == SEXPR_VALUE) &&
+ !strcmp(s->u.s.car->u.s.car->u.value, "vcpu")) {
+ t = s->u.s.car;
vcpu = ipt->number = sexpr_int(t, "vcpu/number");
if ((oln = sexpr_int(t, "vcpu/online")) != 0) {
if (sexpr_int(t, "vcpu/running")) ipt->state = VIR_VCPU_RUNNING;
@@ -2905,14 +2904,14 @@ xenDaemonDomainGetVcpus(virDomainPtr dom
* get sexpr from "(cpumap (x y z...))" and convert values
* to bitmap
*/
- for (t = t->cdr; t->kind == SEXPR_CONS; t = t->cdr)
- if ((t->car->kind == SEXPR_CONS) &&
- (t->car->car->kind == SEXPR_VALUE) &&
- !strcmp(t->car->car->value, "cpumap") &&
- (t->car->cdr->kind == SEXPR_CONS)) {
- for (t = t->car->cdr->car; t->kind == SEXPR_CONS; t = t->cdr)
- if (t->car->kind == SEXPR_VALUE) {
- cpu = strtol(t->car->value, NULL, 0);
+ for (t = t->u.s.cdr; t->kind == SEXPR_CONS; t = t->u.s.cdr)
+ if ((t->u.s.car->kind == SEXPR_CONS) &&
+ (t->u.s.car->u.s.car->kind == SEXPR_VALUE) &&
+ !strcmp(t->u.s.car->u.s.car->u.value, "cpumap") &&
+ (t->u.s.car->u.s.cdr->kind == SEXPR_CONS)) {
+ for (t = t->u.s.car->u.s.cdr->u.s.car; t->kind == SEXPR_CONS; t = t->u.s.cdr)
+ if (t->u.s.car->kind == SEXPR_VALUE) {
+ cpu = strtol(t->u.s.car->u.value, NULL, 0);
if (cpu >= 0 && (VIR_CPU_MAPLEN(cpu+1) <= maplen)) {
VIR_USE_CPU(cpumap, cpu);
}
@@ -3434,8 +3433,8 @@ xenDaemonNumOfDefinedDomains(virConnectP
ret = 0;
- for (_for_i = root, node = root->car; _for_i->kind == SEXPR_CONS;
- _for_i = _for_i->cdr, node = _for_i->car) {
+ for (_for_i = root, node = root->u.s.car; _for_i->kind == SEXPR_CONS;
+ _for_i = _for_i->u.s.cdr, node = _for_i->u.s.car) {
if (node->kind != SEXPR_VALUE)
continue;
ret++;
@@ -3464,12 +3463,12 @@ int xenDaemonListDefinedDomains(virConne
ret = 0;
- for (_for_i = root, node = root->car; _for_i->kind == SEXPR_CONS;
- _for_i = _for_i->cdr, node = _for_i->car) {
+ for (_for_i = root, node = root->u.s.car; _for_i->kind == SEXPR_CONS;
+ _for_i = _for_i->u.s.cdr, node = _for_i->u.s.car) {
if (node->kind != SEXPR_VALUE)
continue;
- names[ret++] = strdup(node->value);
+ names[ret++] = strdup(node->u.value);
if (ret >= maxnames)
break;
}
17 years, 2 months
Fwd: [Libvir] Updated Solaris dom0 patch (part 1)
by Mark Johnson
sorry, missed the cc.....
---------- Forwarded message ----------
From: Mark Johnson <johnson.nh(a)gmail.com>
Date: Sep 28, 2007 4:09 PM
Subject: Re: [Libvir] Updated Solaris dom0 patch (part 1)
To: "Daniel P. Berrange" <berrange(a)redhat.com>
On 9/28/07, Daniel P. Berrange <berrange(a)redhat.com> wrote:
> On Fri, Sep 28, 2007 at 03:03:15PM -0400, Mark Johnson wrote:
> >
> > I've broken this patch up into a few pieces to make
> > it more reviewable and tried to address the comments
> > from the previous patch (Jun 15th'ish if your looking).
> >
> > Here is first part...
> >
> > tested on today's CVS bits on a FC7 dom0
> > (LD_PRELOAD=src/.libs/libvirt.so src/.libs/virsh)
> >
> > One note, it looks like you still need a xend change on
> > FC7 before the no kernel/bootloader option works. It
> > looks like it's close though.. works fine with them
> > of course.
> >
> >
> > More details...
> >
> >
> > [root@fedora solaris]# cat guest.py
> > name = "solaris"
> > vcpus = 1
> > memory = "512"
> >
> > #bootloader = "/usr/bin/pygrub"
> > #kernel = "/platform/i86xpv/kernel/unix"
> > #ramdisk = "/platform/i86pc/boot_archive"
> > extra = "-k"
> >
> > root = "/dev/dsk/c0d0s0"
> > disk = ['file:/export/guests/solaris/disk.img,0,w']
>
> Oooh, that's interesting. Can you explain a little about Solaris paravirt
> disk naming, since it doesn't use xvdN/hdN/sdN style config ?
No, it uses a disk #... 0, 1, 2, 3, 4.. We also have a PV :cdrom
e.g. for an install...
disk = ['file:/tank/guests/install/solaris/66-0624-nd.iso,6:cdrom,r',
'file:/tank/guests/install/solaris/disk.img,0,w']
> Does the
> HVM disk naming still use the named devs ?
Yes. That is the same.
> Also one other question. There is a config option
>
> builder='linux'
>
> Which is never used on Linux since 'linux' is the default. Do you change
> the default on Solaris, or dooes the existing 'linux' builder work just
> fine with Solaris DomU images ? I guess the latter, since the SEXPR
> you have below is using 'linux'.
Yep, we use the linux domain builder...
> > [root@fedora solaris]# xm list -l solaris
> > (domain
> > (on_crash destroy)
> > (uuid 72f9b45e-4be9-bf1f-a500-3707b9c3922c)
> > (bootloader_args )
> > (vcpus 1)
> > (name solaris)
> > (on_poweroff destroy)
> > (on_reboot restart)
> > (bootloader )
>
> Since I notice it has the bootloader bit in the SEXPR, I'm thinking I'll
> tweak our XML generation so it at least includes an empty <bootloade/>
> since there may be tools using libvirt which expect at least one of <os>
> or <bootloader> and using an empty tag may keep them happier.
>
> eg, it'd probably avoid this problem...
OK.
MRJ
> > virsh # console solaris
> > libvir: Xen Daemon error : internal error domain information incomplete, missing kernel & bootloader
> > domain.xml:25: parser error : Opening and ending tag mismatch: os line 4 and domain
> > </domain>
> > ^
> > domain.xml:26: parser error : Premature end of data in tag domain line 1
>
>
> Though obviously your patch fixes that too.
>
> Dan.
> --
> |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=|
> |=- Perl modules: http://search.cpan.org/~danberr/ -=|
> |=- Projects: http://freshmeat.net/~danielpb/ -=|
> |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
>
17 years, 2 months
[Libvir] PATCH: Fix crash parsing input devices for QEMU
by Daniel P. Berrange
There is an edge case in parsing of input devices where if you have a PS2
mouse defined, before a USB tablet, it could generate a null pointer
deference & thus crash. Normally you'd only have one pointer defined, but
one might add a USB tablet for getting a improved mouse experience.
Dan.
--
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=|
|=- Perl modules: http://search.cpan.org/~danberr/ -=|
|=- Projects: http://freshmeat.net/~danielpb/ -=|
|=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
17 years, 2 months
[Libvir] PATCH: Allow remote driver to handle any connection URI
by Daniel P. Berrange
We currently have logic in the remote driver so that it handles the local
QEMU driver URIs, so they get re-directed to the daemon. It also handles
networking APIs for Xen driver. For normal APIs, Xen has the auto-spawned
setuid proxy daemon. This was very useful at the time we wrote it, but it
only supports a handful of operations, and only in read-only mode. One other
factor is that SUSE, for example, do not ship it because it is setuid. I
don't know whether this is just a general policy, or just because they've
not had time to audit it, but that's not very good for their users.
With the development of the remote driver & the flexible UNIX socket perms
& group ownership, or with policykit support it is possible to replace the
proxy with calls straight to the remote daemon. So this patch is the first
step by allowing the remote driver to handle any hypervisor connection URI.
If it doesn't have a hostname or transport specified, then it automatically
tries to connect to the local libvirt daemon over UNIX sockets.
Dan.
--
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=|
|=- Perl modules: http://search.cpan.org/~danberr/ -=|
|=- Projects: http://freshmeat.net/~danielpb/ -=|
|=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
17 years, 2 months
[Libvir] virt-df (a 'df' tool for virtual domains)
by Richard W.M. Jones
Brave (or foolhardy?) souls may want to try out the almost-working
version of 'virt-df' that I wrote:
hg clone http://hg.et.redhat.com/virt/applications/virt-top--devel
Usage is similar to ordinary 'df'. It understands the -h
(human-readable) and -i (show inodes) options. You need to run it on
the dom0, it won't work remotely.
# virt-df.opt -c qemu:///system
debian32kvm /dev/hda (3.9 GiB) /var/lib/xen/images/debian32kvm.img
hda1 3662792 990276 2672516 Linux ext2/3
hda5 232908 Linux swap
[The numbers are 1K blocks total, used, available]
# virt-df.opt -c qemu:///system -h
debian32kvm /dev/hda (3.9 GiB) /var/lib/xen/images/debian32kvm.img
hda1 3.5 GiB 967.1 MiB 2.5 GiB Linux ext2/3
hda5 227.4 MiB Linux swap
From the README file:
virt-df is a 'df' tool for printing out the used and available disk
space in all active and inactive domains. Without this tool you would
need to log in to each domain individually or set up monitoring.
It is only a proof-of-concept. Please bare in mind the following
limitations when using this tool:
(1) It does not work over remote connections. Part of the reason why I
wrote virt-df was to get an idea of how the remote storage API for
libvirt might look.
(2) It only understands a limited set of partition types. Assuming that
the files and partitions that we get back from libvirt / Xen correspond
to block devices in the guests, we can go some way towards manually
parsing those partitions to find out what they contain. We can read the
MBR, EBR, superblocks and so on. However that's a lot of parsing work,
and currently there is no library which understands a wide range of
partition schemes and filesystem types (not even libparted which doesn't
support LVM yet). The Linux kernel does support that, but there's not
really any good way to access that work.
The current implementation uses a hand-coded parser which understands
some simple formats (MBR, EBR, ext2/3, not LVM yet but coming soon). In
future we should use something like libparted.
(3) The statistics you get are delayed. The real state of, for example,
an ext2 filesystem is only stored in the memory of the guest's kernel.
The ext2 superblock contains some meta-information about blocks used and
free, but this superblock is not up to date. In fact the guest kernel
may not update it even on a 'sync', not until the filesystem is
unmounted. Some operations do appear to write the superblock, for
example fsync(2) [that is my reading of the ext2/3 source code at least].
$ wc -l virt-df/*.ml
84 virt-df/virt_df_ext2.ml
24 virt-df/virt_df_linux_swap.ml
22 virt-df/virt_df_lvm2.ml
5 virt-df/virt_df_main.ml
460 virt-df/virt_df.ml
595 total
Rich.
--
Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod
Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in
England and Wales under Company Registration No. 03798903
17 years, 2 months
[Libvir] topology test program
by beth kon
Daniel,
As we discussed, here is the program I was using for testing different
topology strings.
--
Elizabeth Kon (Beth)
IBM Linux Technology Center
Open Hypervisor Team
email: eak(a)us.ibm.com
17 years, 2 months
[Libvir] trouble using ssh tunnel for remote hypervisor
by Guillaume Rousse
Hello.
I'm trying to use ssh tunnel for remote hypervisor access. However, I'm
can't make it working...
[guillaume@oberkampf ~]$ LC_ALL=C virsh --connect
xen+ssh://root@acacia.futurs.inria.fr list --all
libvir: error : could not connect to xen://
error: failed to connect to the hypervisor
error: no valid connection
On the remote host:
[root@acacia ~]# libvirtd --verbose
libvir: error : could not connect to xen://
It seems the error lies between libvirtd and the local hypervisor. And
indeed, local usage of virsh with xen:// URLs fail:
[root@acacia ~]# LC_ALL=C virsh -c xen:// list
libvir: error : could not connect to xen://
error: failed to connect to the hypervisor
error: no valid connection
Using xen:///, instead of xen://, as explained at
http://libvirt.org/uri.html, is OK, despite a few error messages:
[root@acacia ~]# LC_ALL=C virsh -c xen:/// list
libvir: Remote error : No such file or directory
libvir: warning : Failed to find the network: Is the daemon running ?
Id Name State
----------------------------------
0 Domain-0 running
1 barman blocked
2 cocktail blocked
3 mojito blocked
>From the documentation, it seems xen:// transport implies TLS, and
requires an host name, so it is quite normal it fails here (I didn't
generated any certificate). But how can I force libvirtd to use xen:///
transport then ? I don't see anything related in libvirt configuration
documentation at http://libvirt.org/remote.html ? Neither about how to
configure it for listening on unix transport, as explained in svn+ssh
transport requirements on the same page (but I presume it is the default) ?
Also, from where does those error and warning come ?
[root@acacia ~]# LC_ALL=C virsh -c xen:/// list
libvir: Remote error : No such file or directory
libvir: warning : Failed to find the network: Is the daemon running ?
[..]
I'm using libvirt 0.3.2 on mandriva 2007.1, with xen 3.1.0.
--
Guillaume Rousse
Moyens Informatiques - INRIA Futurs
Tel: 01 69 35 69 62
17 years, 2 months