---
docs/formatnwfilter.html.in | 10 ++
docs/schemas/nwfilter.rng | 16 ++++
src/conf/nwfilter_conf.c | 115
+++++++++++++++++++++++++++---
src/conf/nwfilter_conf.h | 9 ++
src/libvirt_private.syms | 1
src/nwfilter/nwfilter_ebiptables_driver.c | 9 ++
tests/nwfilterxml2xmlin/tcp-test.xml | 12 +++
tests/nwfilterxml2xmlout/tcp-test.xml | 12 +++
8 files changed, 174 insertions(+), 10 deletions(-)
Index: libvirt-acl/src/conf/nwfilter_conf.c
===================================================================
--- libvirt-acl.orig/src/conf/nwfilter_conf.c
+++ libvirt-acl/src/conf/nwfilter_conf.c
@@ -5,7 +5,8 @@
* Copyright (C) 2006-2011 Red Hat, Inc.
* Copyright (C) 2006-2008 Daniel P. Berrange
*
- * Copyright (C) 2010 IBM Corporation
+ * Copyright (C) 2010-2011 IBM Corporation
+ * Copyright (C) 2010-2011 Stefan Berger
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -726,17 +727,23 @@ printStringItems(virBufferPtr buf, const
int32_t flags, const char *sep)
{
unsigned int i, c = 0;
- int32_t last_attr = 0;
+ int32_t mask = 0x1;
- for (i = 0; int_map[i].val; i++) {
- if (last_attr != int_map[i].attr &&
- flags & int_map[i].attr) {
- if (c >= 1)
- virBufferVSprintf(buf, "%s", sep);
- virBufferVSprintf(buf, "%s", int_map[i].val);
- c++;
+ while (mask) {
+ if ((mask & flags)) {
+ for (i = 0; int_map[i].val; i++) {
+ if (mask == int_map[i].attr) {
+ if (c >= 1)
+ virBufferVSprintf(buf, "%s", sep);
+ virBufferVSprintf(buf, "%s", int_map[i].val);
+ c++;
+ }
+ }
+ flags ^= mask;
+ if (!flags)
+ break;
}
- last_attr = int_map[i].attr;
+ mask <<= 1;
}
return 0;
@@ -799,6 +806,87 @@ stateFormatter(virBufferPtr buf,
}
+
+static const struct int_map tcpFlags[] = {
+ INTMAP_ENTRY(0x1 , "FIN"),
+ INTMAP_ENTRY(0x2 , "SYN"),
+ INTMAP_ENTRY(0x4 , "RST"),
+ INTMAP_ENTRY(0x8 , "PSH"),
+ INTMAP_ENTRY(0x10, "ACK"),
+ INTMAP_ENTRY(0x20, "URG"),
+ INTMAP_ENTRY(0x3F, "ALL"),
+ INTMAP_ENTRY(0x0 , "NONE"),
+ INTMAP_ENTRY_LAST
+};
+
+
+static bool
+tcpFlagsValidator(enum attrDatatype datatype ATTRIBUTE_UNUSED, union
data *val,
+ virNWFilterRuleDefPtr nwf ATTRIBUTE_UNUSED,
+ nwItemDesc *item)
+{
+ bool rc = false;
+ char *s_mask = val->c;
+ char *sep = strchr(val->c, '/');
+ char *s_flags;
+ int32_t mask = 0, flags = 0;
+
+ if (!sep)
+ return false;
+
+ s_flags = sep + 1;
+
+ *sep = '\0';
+
+ if (!parseStringItems(tcpFlags, s_mask , &mask , ',') &&
+ !parseStringItems(tcpFlags, s_flags, &flags, ',')) {
+ item->u.tcpFlags.mask = mask & 0x3f;
+ item->u.tcpFlags.flags = flags & 0x3f;
+ rc = true;
+ }
+
+ *sep = '/';
+
+ return rc;
+}
+
+
+static void
+printTCPFlags(virBufferPtr buf, uint8_t flags)
+{
+ if (flags == 0)
+ virBufferAddLit(buf, "NONE");
+ else if (flags == 0x3f)
+ virBufferAddLit(buf, "ALL");
+ else
+ printStringItems(buf, tcpFlags, flags, ",");
+}
+
+
+void
+virNWFilterPrintTCPFlags(virBufferPtr buf,
+ uint8_t mask, char sep, uint8_t flags)
+{
+ printTCPFlags(buf, mask);
+ virBufferAddChar(buf, sep);
+ printTCPFlags(buf, flags);
+}
+
+
+static bool
+tcpFlagsFormatter(virBufferPtr buf,
+ virNWFilterRuleDefPtr nwf ATTRIBUTE_UNUSED,
+ nwItemDesc *item)
+{
+ virNWFilterPrintTCPFlags(buf,
+ item->u.tcpFlags.mask,
+ '/',
+ item->u.tcpFlags.flags);
+
+ return true;
+}
+
+
#define COMMON_MAC_PROPS(STRUCT) \
{\
.name = SRCMACADDR,\
@@ -1104,6 +1192,13 @@ static const virXMLAttr2Struct tcpAttrib
.datatype = DATATYPE_UINT8 | DATATYPE_UINT8_HEX,
.dataIdx = offsetof(virNWFilterRuleDef,
p.tcpHdrFilter.dataTCPOption),
},
+ {
+ .name = "flags",
+ .datatype = DATATYPE_STRING,
+ .dataIdx = offsetof(virNWFilterRuleDef,
p.tcpHdrFilter.dataTCPFlags),
+ .validator = tcpFlagsValidator,
+ .formatter = tcpFlagsFormatter,
+ },
COMMENT_PROP_IPHDR(tcpHdrFilter),
{
.name = NULL,
Index: libvirt-acl/src/conf/nwfilter_conf.h
===================================================================
--- libvirt-acl.orig/src/conf/nwfilter_conf.h
+++ libvirt-acl/src/conf/nwfilter_conf.h
@@ -122,6 +122,10 @@ struct _nwItemDesc {
uint16_t u16;
char protocolID[10];
char *string;
+ struct {
+ uint8_t mask;
+ uint8_t flags;
+ } tcpFlags;
} u;
};
@@ -242,6 +246,7 @@ struct _tcpHdrFilterDef {
ipHdrDataDef ipHdr;
portDataDef portData;
nwItemDesc dataTCPOption;
+ nwItemDesc dataTCPFlags;
};
@@ -667,6 +672,10 @@ void virNWFilterCallbackDriversLock(void
void virNWFilterCallbackDriversUnlock(void);
+void virNWFilterPrintTCPFlags(virBufferPtr buf, uint8_t mask,
+ char sep, uint8_t flags);
+
+
VIR_ENUM_DECL(virNWFilterRuleAction);
VIR_ENUM_DECL(virNWFilterRuleDirection);
VIR_ENUM_DECL(virNWFilterRuleProtocol);
Index: libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c
===================================================================
--- libvirt-acl.orig/src/nwfilter/nwfilter_ebiptables_driver.c
+++ libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c
@@ -1204,6 +1204,15 @@ _iptablesCreateRuleInstance(int directio
&prefix))
goto err_exit;
+ if (HAS_ENTRY_ITEM(&rule->p.tcpHdrFilter.dataTCPFlags)) {
+ virBufferVSprintf(&buf, " %s --tcp-flags ",
+
ENTRY_GET_NEG_SIGN(&rule->p.tcpHdrFilter.dataTCPFlags));
+ virNWFilterPrintTCPFlags(&buf,
+ rule->p.tcpHdrFilter.dataTCPFlags.u.tcpFlags.mask,
+ ' ',
+ rule->p.tcpHdrFilter.dataTCPFlags.u.tcpFlags.flags);
+ }
+
if (iptablesHandlePortData(&buf,
vars,
&rule->p.tcpHdrFilter.portData,
Index: libvirt-acl/docs/schemas/nwfilter.rng
===================================================================
--- libvirt-acl.orig/docs/schemas/nwfilter.rng
+++ libvirt-acl/docs/schemas/nwfilter.rng
@@ -81,6 +81,7 @@
+
@@ -184,6 +185,7 @@
+
@@ -606,6 +608,14 @@
+
+
+
+
+
+
+
+
@@ -872,4 +882,10 @@
((NEW|ESTABLISHED|RELATED|INVALID)(,(NEW|ESTABLISHED|RELATED|INVALID))*|NONE)
+
+
+
+ ((SYN|ACK|URG|PSH|FIN|RST)(,(SYN|ACK|URG|PSH|FIN|RST))*|ALL|NONE)/((SYN|ACK|URG|PSH|FIN|RST)(,(SYN|ACK|URG|PSH|FIN|RST))*|ALL|NONE)
+
+
Index: libvirt-acl/docs/formatnwfilter.html.in
===================================================================
--- libvirt-acl.orig/docs/formatnwfilter.html.in
+++ libvirt-acl/docs/formatnwfilter.html.in
@@ -755,6 +755,11 @@
STRING |
comma separated list of NEW,ESTABLISHED,RELATED,INVALID or NONE |
+
+ flags (Since 0.9.0) |
+ STRING |
+ TCP-only: format of mask/flags with mask and flags each being a
comma separated list of SYN,ACK,URG,PSH,FIN,RST or NONE or ALL |
+
@@ -1040,6 +1045,11 @@
STRING |
comma separated list of NEW,ESTABLISHED,RELATED,INVALID or NONE |
+
+ flags (Since 0.8.5) |
+ STRING |
+ format of mask/flags with mask and flags each being a comma
separated list of SYN,ACK,URG,PSH,FIN,RST or NONE or ALL |
+
Index: libvirt-acl/src/libvirt_private.syms
===================================================================
--- libvirt-acl.orig/src/libvirt_private.syms
+++ libvirt-acl/src/libvirt_private.syms
@@ -683,6 +683,7 @@ virNWFilterObjRemove;
virNWFilterObjSaveDef;
virNWFilterObjUnlock;
virNWFilterPrintStateMatchFlags;
+virNWFilterPrintTCPFlags;
virNWFilterRegisterCallbackDriver;
virNWFilterRuleActionTypeToString;
virNWFilterRuleProtocolTypeToString;
Index: libvirt-acl/tests/nwfilterxml2xmlin/tcp-test.xml
===================================================================
--- libvirt-acl.orig/tests/nwfilterxml2xmlin/tcp-test.xml
+++ libvirt-acl/tests/nwfilterxml2xmlin/tcp-test.xml
@@ -19,4 +19,16 @@
srcportstart='255' srcportend='256'
dstportstart='65535' dstportend='65536'/>
+
+
+
+
+
+
+
+
+
+
+
+
Index: libvirt-acl/tests/nwfilterxml2xmlout/tcp-test.xml
===================================================================
--- libvirt-acl.orig/tests/nwfilterxml2xmlout/tcp-test.xml
+++ libvirt-acl/tests/nwfilterxml2xmlout/tcp-test.xml
@@ -9,4 +9,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
From stefanb at linux.vnet.ibm.com Fri Apr 1 16:17:32 2011
From: stefanb at linux.vnet.ibm.com (Stefan Berger)
Date: Fri, 01 Apr 2011 12:17:32 -0400
Subject: [libvirt] [TCK][PATCH] nwfilter: test support for TCP flags
evaluation
Message-ID: <4D95FA9C.4070706@linux.vnet.ibm.com>
This patch extends an existing test with test cases for the TCP flags.
Signed-off-by: Stefan Berger
---
scripts/nwfilter/nwfilterxml2fwallout/tcp-test.fwall | 4 ++++
scripts/nwfilter/nwfilterxml2xmlin/tcp-test.xml | 12 ++++++++++++
2 files changed, 16 insertions(+)
Index: libvirt-tck/scripts/nwfilter/nwfilterxml2fwallout/tcp-test.fwall
===================================================================
--- libvirt-tck.orig/scripts/nwfilter/nwfilterxml2fwallout/tcp-test.fwall
+++ libvirt-tck/scripts/nwfilter/nwfilterxml2fwallout/tcp-test.fwall
@@ -10,6 +10,10 @@ target prot opt source
ACCEPT tcp -- 10.1.2.3 0.0.0.0/0 DSCP
match 0x02state ESTABLISHED ctdir ORIGINAL
ACCEPT tcp -- 10.1.2.3 0.0.0.0/0 MAC
01:02:03:04:05:06 DSCP match 0x21tcp spts:20:21 dpts:100:1111
ACCEPT tcp -- 10.1.2.3 0.0.0.0/0 MAC
01:02:03:04:05:06 DSCP match 0x3ftcp spts:255:256 dpt:65535
+ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp
flags:0x02/0x3F
+ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp
flags:0x02/0x12
+ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp
flags:0x04/0x00
+ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp
flags:0x08/0x00
#iptables -L HI-vnet0 -n
Chain HI-vnet0 (1 references)
target prot opt source destination
Index: libvirt-tck/scripts/nwfilter/nwfilterxml2xmlin/tcp-test.xml
===================================================================
--- libvirt-tck.orig/scripts/nwfilter/nwfilterxml2xmlin/tcp-test.xml
+++ libvirt-tck/scripts/nwfilter/nwfilterxml2xmlin/tcp-test.xml
@@ -19,4 +19,16 @@
srcportstart='255' srcportend='256'
dstportstart='65535' dstportend='65536'/>
+
+
+
+
+
+
+
+
+
+
+
+
From eblake at redhat.com Fri Apr 1 16:19:20 2011
From: eblake at redhat.com (Eric Blake)
Date: Fri, 01 Apr 2011 10:19:20 -0600
Subject: [libvirt] [PATCH 1/6] virNodeGetCpuTime: Expose new API
In-Reply-To: <20110401105548.a78607f7.usui@mxm.nes.nec.co.jp>
References: <20110401103833.8b66b57e.usui@mxm.nes.nec.co.jp>
<20110401105548.a78607f7.usui@mxm.nes.nec.co.jp>
Message-ID: <4D95FB08.20802@redhat.com>
On 03/31/2011 07:55 PM, Minoru Usui wrote:
> virNodeGetCpuTime: Expose new API
>
> include/libvirt/libvirt.h.in | 26 ++++++++++++++++++++++++++
> src/libvirt_public.syms | 1 +
> 2 files changed, 27 insertions(+), 0 deletions(-)
>
> +/**
> + * virNodeCpuTime:
> + *
> + * a virNodeCpuTime is a structure filled by virNodeGetCpuTime() and providing
> + * the information for the cpu time of Node.
> + */
> +
> +typedef struct _virNodeCpuTime virNodeCpuTime;
> +
> +struct _virNodeCpuTime {
> + unsigned long long user;
> + unsigned long long system;
> + unsigned long long idle;
> + unsigned long long iowait;
> +};
Can we portably get all of this information on Windows? If not, how do
you express which values we don't know how to obtain?
> @@ -593,6 +616,9 @@ int virNodeGetInfo (virConnectPtr conn,
> virNodeInfoPtr info);
> char * virConnectGetCapabilities (virConnectPtr conn);
>
> +int virNodeGetCpuTime (virConnectPtr conn,
> + virNodeCpuTimePtr cpu_time);
> +
Rather than locking ourselves into yet another inflexible API (no flags
parameter and a hard-coded struct means no way to extend this if we ever
come up with some new stat to query), should we instead be following the
lead of getMemoryParameters which takes a typed-name/value array to pass
an arbitrary number of parameters, which allows extension without a new API?
> +++ b/src/libvirt_public.syms
> @@ -434,6 +434,7 @@ LIBVIRT_0.9.0 {
> virEventRunDefaultImpl;
> virStorageVolDownload;
> virStorageVolUpload;
> + virNodeGetCpuTime;
> } LIBVIRT_0.8.8;
While I think that something along the lines of this API is appropriate
for libvirt (indeed, knowing a host's CPU utilization can indeed be a
factor for upper-level management software in deciding whether to
migrate another domain on or off of the machine), it's too late to put
it into 0.9.0. We'd be setting bad precedent by accepting this after
the first release candidate did a feature freeze, so you'd need to
adjust this to 0.9.1.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From berrange at redhat.com Fri Apr 1 16:24:18 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Fri, 1 Apr 2011 17:24:18 +0100
Subject: [libvirt] [TCK][PATCH] nwfilter: test support for TCP flags
evaluation
In-Reply-To: <4D95FA9C.4070706@linux.vnet.ibm.com>
References: <4D95FA9C.4070706@linux.vnet.ibm.com>
Message-ID: <20110401162418.GM29510@redhat.com>
On Fri, Apr 01, 2011 at 12:17:32PM -0400, Stefan Berger wrote:
> This patch extends an existing test with test cases for the TCP flags.
>
> Signed-off-by: Stefan Berger
>
> ---
> scripts/nwfilter/nwfilterxml2fwallout/tcp-test.fwall | 4 ++++
> scripts/nwfilter/nwfilterxml2xmlin/tcp-test.xml | 12 ++++++++++++
> 2 files changed, 16 insertions(+)
>
> Index: libvirt-tck/scripts/nwfilter/nwfilterxml2fwallout/tcp-test.fwall
> ===================================================================
> --- libvirt-tck.orig/scripts/nwfilter/nwfilterxml2fwallout/tcp-test.fwall
> +++ libvirt-tck/scripts/nwfilter/nwfilterxml2fwallout/tcp-test.fwall
> @@ -10,6 +10,10 @@ target prot opt source
> ACCEPT tcp -- 10.1.2.3 0.0.0.0/0 DSCP
> match 0x02state ESTABLISHED ctdir ORIGINAL
> ACCEPT tcp -- 10.1.2.3 0.0.0.0/0 MAC
> 01:02:03:04:05:06 DSCP match 0x21tcp spts:20:21 dpts:100:1111
> ACCEPT tcp -- 10.1.2.3 0.0.0.0/0 MAC
> 01:02:03:04:05:06 DSCP match 0x3ftcp spts:255:256 dpt:65535
> +ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp
> flags:0x02/0x3F
> +ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp
> flags:0x02/0x12
> +ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp
> flags:0x04/0x00
> +ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp
> flags:0x08/0x00
> #iptables -L HI-vnet0 -n
> Chain HI-vnet0 (1 references)
> target prot opt source destination
> Index: libvirt-tck/scripts/nwfilter/nwfilterxml2xmlin/tcp-test.xml
> ===================================================================
> --- libvirt-tck.orig/scripts/nwfilter/nwfilterxml2xmlin/tcp-test.xml
> +++ libvirt-tck/scripts/nwfilter/nwfilterxml2xmlin/tcp-test.xml
> @@ -19,4 +19,16 @@
> srcportstart='255' srcportend='256'
> dstportstart='65535' dstportend='65536'/>
>
> +
> +
> +
> +
> +
> +
> +
> +
> +
> +
> +
> +
>
ACK
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From eblake at redhat.com Fri Apr 1 16:24:53 2011
From: eblake at redhat.com (Eric Blake)
Date: Fri, 01 Apr 2011 10:24:53 -0600
Subject: [libvirt] [PATCH] do not lock vm while allocating memory
In-Reply-To: <4D92DFD9.6000700@cn.fujitsu.com>
References: <4D92DFD9.6000700@cn.fujitsu.com>
Message-ID: <4D95FC55.8080800@redhat.com>
On 03/30/2011 01:46 AM, Wen Congyang wrote:
> There is no need to lock vm while allocating memory. If allocating
> memory failed, we forgot to unlock vm.
>
> ---
> src/qemu/qemu_process.c | 3 +--
> 1 files changed, 1 insertions(+), 2 deletions(-)
>
> diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
> index e31e1b4..e74e0f1 100644
> --- a/src/qemu/qemu_process.c
> +++ b/src/qemu/qemu_process.c
> @@ -525,8 +525,6 @@ qemuProcessHandleGraphics(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
> virDomainEventGraphicsSubjectPtr subject = NULL;
> int i;
>
> - virDomainObjLock(vm);
> -
> if (VIR_ALLOC(localAddr) < 0)
> goto no_memory;
> localAddr->family = localFamily;
> @@ -560,6 +558,7 @@ qemuProcessHandleGraphics(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
> subject->nidentity++;
> }
>
> + virDomainObjLock(vm);
ACK. It only affects the OOM path, but is worth including in 0.9.0.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From eblake at redhat.com Fri Apr 1 16:26:15 2011
From: eblake at redhat.com (Eric Blake)
Date: Fri, 01 Apr 2011 10:26:15 -0600
Subject: [libvirt] [PATCH] fix memory leak in qemuProcessHandleGraphics()
In-Reply-To: <4D92DFE1.4070602@cn.fujitsu.com>
References: <4D92DFE1.4070602@cn.fujitsu.com>
Message-ID: <4D95FCA7.3070801@redhat.com>
On 03/30/2011 01:46 AM, Wen Congyang wrote:
> If strdup("x509dname") or strdup("saslUsername") success, but
> strdup(x509dname) or strdup(saslUsername) failed, subject->nidentity
> is not the num elements of subject->identities, and we will leak some
> memory.
>
> ---
> src/qemu/qemu_process.c | 12 ++++++------
> 1 files changed, 6 insertions(+), 6 deletions(-)
ACK - another OOM-only error appropriate for 0.9.0. I'm guessing you
found it by inspection?
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From eblake at redhat.com Fri Apr 1 16:28:59 2011
From: eblake at redhat.com (Eric Blake)
Date: Fri, 01 Apr 2011 10:28:59 -0600
Subject: [libvirt] [BUG] Managed save qemu state gets deleted after
failed resume
In-Reply-To: <201103301024.50356.hahn@univention.de>
References: <201103301024.50356.hahn@univention.de>
Message-ID: <4D95FD4B.9080008@redhat.com>
On 03/30/2011 02:24 AM, Philipp Hahn wrote:
> Hello,
>
> I haven't had time to provide a fix, but still want you to inform you about a
> bug: If resuming a saved VM fails with Qemu-0.14, the managed save state
> file /var/lib/libvirt/qemu/save/$VM.save is still deleted. I think it would
> be better to only delete the state after an successful resume.
Then we would get multiple failures on every resume attempt. However, I
tend to agree with you that data loss in any form is bad, and this is a
form of data loss.
> -device usb-tablet,id=input0 -vnc 0.0.0.0:5 -k de -vga cirrus -device
> virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 -option-rom
> /usr/share/kvm/pxe-rtl8139.bin
> Failed to allocate 2147483648 B: Cannot allocate memory
Especially bad that it looks like a transient ENOMEM condition can cause
the data loss (that is, if I'm interpreting your log correctly, then you
can trigger this condition by temporarily consuming too much memory in
the host, trying to resume a target, then reducing memory pressure, and
try to resume again but now you've lost the state file to resume from).
>
> This issue is tracked in our (German) bug-tracker at
>
Thanks for the link.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From eblake at redhat.com Fri Apr 1 16:31:42 2011
From: eblake at redhat.com (Eric Blake)
Date: Fri, 01 Apr 2011 10:31:42 -0600
Subject: [libvirt] [PATCH v2 0/4] configure inactive domains' maximum
memory size
In-Reply-To: <4D940EEE.2090603@jp.fujitsu.com>
References: <4D940EEE.2090603@jp.fujitsu.com>
Message-ID: <4D95FDEE.8060609@redhat.com>
On 03/30/2011 11:19 PM, Taku Izumi wrote:
> Hi all,
>
> This patchset enables us to configure inactive domain's maximum memory
> size. I redesigned according to Daniel-san's commnet.
> The following patchset is the prerequisite of these.
> => http://www.redhat.com/archives/libvir-list/2011-March/msg01057.html
My sincere apologies at the delay on these series. I've been so focused
on locking bugs and libvirtd crashers that I haven't had a chance to
properly review any of the persistent settings patches in time for
inclusion in 0.9.0. My justification is that you can always achieve
persistent settings (albeit with undue pain) by raw XML editing, so this
is just an enhancement request rather than a bug fix. However, now that
we've missed the feature freeze deadline for 0.9.0, you have my promise
that I will be reviewing this next week for inclusion in 0.9.1.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From eblake at redhat.com Fri Apr 1 16:40:07 2011
From: eblake at redhat.com (Eric Blake)
Date: Fri, 01 Apr 2011 10:40:07 -0600
Subject: [libvirt] How many functions that can't be used within libvirt
In-Reply-To:
References:
Message-ID: <4D95FFE7.1000405@redhat.com>
On 04/01/2011 12:10 AM, SanitYey o wrote:
>
> Hello,
> I've tested some functions of libvirt don't work. Could some people give me a reasonable explanation about these functions? Why do these function don't work? Or if there is anything wrong of my understanding.
> 1.virsh # migrate 1 xen+ssh://root at 172.16.201.183/Password: error: POST operation failed: xend_post: error from xen daemon: (xend.err "can't connect: (-2, 'Name or service not known')")
Not sure why you got a failure here; xen migration should indeed work
(although I haven't tried it myself, since I mostly use kvm).
>
> 2.virsh # dommemstat 5error: Failed to get memory statistics for domain 5error: this function is not supported by the hypervisor: virDomainMemoryStats
Not all hypervisors can support all APIs. In some cases, it's merely
because no one has contributed the glue code to query the information
available from the hypervisor and convert it into the libvirt reply, in
other cases it is truly because the hypervisor does not track that
information in the first place. I'm assuming that this is still in
regards to your xen:/// connection?
>
> 3.virsh # dump 5 fileerror: Failed to core dump domain 5 to fileerror: POST operation failed: xend_post: error from xen daemon: (xend.err 'Too many values for live')
Not sure what failed there; does looking under /var/log/libvirt for a
domain-specific log give any more clues?
>
> 4.virsh # iface-list error: Failed to list active interfaceserror: this function is not supported by the hypervisor: virConnectNumOfInterfaces
Same category as 2.
>
> 5.virsh # vncdisplay 5:1
> virsh # vncdisplay 41:0
>
> 6.virsh # snapshot-create 42 snapshot.xml error: Failed to create snapshot snapshot.xml for domain 42
I don't think snapshot-create has been ported to xen yet; and even for
qemu-kvm, it pretty much only works with qcow2 images at the moment.
>
> 7.NWFILTER functions
> Thank you very much!
Again, I'm not sure if this has been ported to xen.
You are welcome to help out by writing code for some of the missing
functionality! Most of the current libvirt contributors tend to use
qemu-kvm or the brand-new libxenlight interface to xen, so we could use
more support from active xen users in developing code to improve the
older xen:/// management interfaces.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From eblake at redhat.com Fri Apr 1 16:47:48 2011
From: eblake at redhat.com (Eric Blake)
Date: Fri, 01 Apr 2011 10:47:48 -0600
Subject: [libvirt] [PATCH 1/4] vcpupin: inroduce a new libvir
API (virDomainPinVcpuFlags)
In-Reply-To: <4D94133A.30806@jp.fujitsu.com>
References: <4D94124A.1090808@jp.fujitsu.com> <4D94133A.30806@jp.fujitsu.com>
Message-ID: <4D9601B4.60206@redhat.com>
On 03/30/2011 11:38 PM, Taku Izumi wrote:
>
> This patch introduces a new libvirt API (virDomainPinVcpuFlags)
>
> Signed-off-by: Taku Izumi
> /**
> + * virDomainPinVcpuFlags:
> + * @domain: pointer to domain object, or NULL for Domain0
> + * @vcpu: virtual CPU number
> + * @cpumap: pointer to a bit map of real CPUs (in 8-bit bytes) (IN)
> + * Each bit set to 1 means that correspoinding CPU is usable.
s/correspoinding/corresponding/
> + * Bytes are stored in little-endian order: CPU0-7, 8-15...
> + * In each byte, lowest CPU number is least significant bit.
> + * @maplen: number of bytes in cpumap, from 1 up to size of CPU map in
> + * underlying virtualization system (Xen...).
> + * If maplen < size, missing bytes are set to zero.
> + * If maplen < size, failure code is returned.
s/>/
> + * @flags: an OR'ed set of virDomainVcpuFlags
Is VIR_DOMAIN_VCPU_MAXIMUM really applicable here? The docs should
probably mention that it is a subset of virDomainVcpuFlags.
> + *
> + * Dynamically change the real CPUs which can be allocated to a virtual CPU.
> + * This function requires privileged access to the hypervisor.
> + *
> + * @flags must include VIR_DOMAIN_VCPU_LIVE to affect a running domain
> + * (which may fail if domain is not active), or VIR_DOMAIN_MEM_CONFIG to
s/VIR_DOMAIN_MEM_CONFIG/VIR_DOMAIN_VCPU_CONFIG/
> + * affect the next boot via the XML description of the domain.
> + * Both flags may be set.
> + *
> + * Returns 0 in case of success, -1 in case of failure.
> + *
> + */
> +int
> +virDomainPinVcpuFlags(virDomainPtr domain, unsigned int vcpu,
> + unsigned char *cpumap, int maplen, unsigned int flags)
> +{
> Index: libvirt/src/libvirt_public.syms
> ===================================================================
> --- libvirt.orig/src/libvirt_public.syms
> +++ libvirt/src/libvirt_public.syms
> @@ -434,6 +434,7 @@ LIBVIRT_0.9.0 {
> virEventRunDefaultImpl;
> virStorageVolDownload;
> virStorageVolUpload;
> + virDomainPinVcpuFlags;
> } LIBVIRT_0.8.8;
We've missed the 0.9.0 feature freeze, can you adjust this patch series
to be for 0.9.1?
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From eblake at redhat.com Fri Apr 1 16:52:22 2011
From: eblake at redhat.com (Eric Blake)
Date: Fri, 01 Apr 2011 10:52:22 -0600
Subject: [libvirt] [PATCH 2/4] vcpupin: implement the code to address
the new API in the qemu driver
In-Reply-To: <4D942E36.3060708@redhat.com>
References: <4D94124A.1090808@jp.fujitsu.com> <4D94136C.80504@jp.fujitsu.com>
<4D942E36.3060708@redhat.com>
Message-ID: <4D9602C6.3000107@redhat.com>
On 03/31/2011 01:33 AM, Osier Yang wrote:
>
> This allows both "LIVE" and "CONFIG" are set, and you use two
> "if" clauses later for both of them, (
> if (flags& VIR_DOMAIN_VCPU_CONFIG), and
> if (flags& VIR_DOMAIN_VCPU_LIVE) ) so there should be problem.
>
> IMHO it should be: Exactly one of "LIVE" or "CONFIG" is set.
No, it should be perfectly acceptable to accept both at once (and some
hypervisors may reject LIVE in isolation, as they can only affect LIVE
and CONFIG simultaneously).
We may _also_ want to document that if neither LIVE nor CONFIG is set,
then we instead default to the current state of the domain (LIVE if it
is active, CONFIG if it is just defined), as that has proved to be a
handy shortcut.
We're not very consistent on those semantics on existing APIs (so
someone will have to read the docs for each API to learn which setting
is which, due to backwards compatibility), but for future APIs it is
best to shoot for:
flags = 0 - default to LIVE or CONFIG as appropriate
flags = LIVE - temporary change - affect running guest but not
persistent (error if not running)
flags = CONFIG - config change - affect next boot but not running guest
(error if guest is transient and running, since there is no persistent
state for transient guests)
flags = LIVE|CONFIG - affect running guest and affect next boot (error
if guest is not running, or if guest is transient)
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From eblake at redhat.com Fri Apr 1 17:45:17 2011
From: eblake at redhat.com (Eric Blake)
Date: Fri, 01 Apr 2011 11:45:17 -0600
Subject: [libvirt] [PATCH] add sendevent command and related APIs
In-Reply-To: <4D95A00A.3040901@cn.fujitsu.com>
References: <4D95A00A.3040901@cn.fujitsu.com>
Message-ID: <4D960F2D.4040909@redhat.com>
On 04/01/2011 03:51 AM, Lai Jiangshan wrote:
> Enable libvirt send some events to the guest.
> This command currently only supports NMI and key events.
>
> Signed-off-by: Lai Jiangshan
Would you mind resending this split into several patches? For example,
see how
https://www.redhat.com/archives/libvir-list/2011-April/msg00052.html
divided a new API into 7 patches:
Michal Privoznik (7):
screenshot: Defining the public API
screenshot: Defining the internal API
screenshot: Implementing the public API
screenshot: Implementing the remote protocol
screenshot: Expose the new API in virsh
qemu: Implement the driver methods
vbox: Implement the driver methods
By separating definition, public access, virsh use, and driver
implementation into separate patches, it becomes easier to review. Each
division should still cleanly compile. See also
http://libvirt.org/api_extension.html (although it predates some of the
recent changes such as adding libxl and dropping OpenNebula, it is still
a good reference).
> +++ b/src/libvirt.c
> @@ -5245,6 +5245,94 @@ error:
> }
>
> /**
> + * virDomainSendEvnetNMI:
s/Evnet/Event/
> + * @domain: pointer to domain object, or NULL for Domain0
> + * @vcpu: the virtual CPU id to send NMI to
> + *
> + * Send NMI to a special vcpu of the guest
s/special/specified/
> + *
> + * Returns 0 in case of success, -1 in case of failure.
> + */
> +
> +int virDomainSendEventNMI(virDomainPtr domain, unsigned int vcpu)
Absolutely must have a flags argument for future extension (even if the
only supported flags value is 0 for now).
> +
> +/**
> + * virDomainSendEventKey:
> + * @domain: pointer to domain object, or NULL for Domain0
> + * @key: the string of key or key sequence
> + *
> + * Send a special key or key sequence to the guest
> + *
> + * Returns 0 in case of success, -1 in case of failure.
> + */
> +
> +int virDomainSendEventKey(virDomainPtr domain, const char *key)
Needs a flags argument. Also, what is the format of a key sequence?
There's several layers of key events, from what a keyboard sends, to
what the OS driver encodes, to what X encodes, and so forth. If the
format ever needs to include a NUL byte, then you need a length
parameter. I'm worried that this is a bit underspecified. Do we know
in advance which keys are acceptable (I'm assuming this is for SysRq
sequences), in which case an enum value might be better than a raw char*.
> +++ b/src/libvirt_public.syms
> @@ -434,6 +434,8 @@ LIBVIRT_0.9.0 {
> virEventRunDefaultImpl;
> virStorageVolDownload;
> virStorageVolUpload;
> + virDomainSendEventNMI;
> + virDomainSendEventKey;
> } LIBVIRT_0.8.8;
This is too late for the 0.9.0 feature freeze cutoff; when you split
this into multiple patches, can you rebase it to be targetting 0.9.1?
I haven't closely reviewed the rest of the patch yet, but think that the
overall idea of being able to inject NMI and SysRq input to the virtual
hardware of the guest is worth adding.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From eblake at redhat.com Fri Apr 1 17:53:18 2011
From: eblake at redhat.com (Eric Blake)
Date: Fri, 01 Apr 2011 11:53:18 -0600
Subject: [libvirt] [PATCH] nwfilters: support for TCP flags evaluation
In-Reply-To: <4D95FA91.5080103@linux.vnet.ibm.com>
References: <4D95FA91.5080103@linux.vnet.ibm.com>
Message-ID: <4D96110E.4080907@redhat.com>
On 04/01/2011 10:17 AM, Stefan Berger wrote:
> This patch adds support for the evaluation of TCP flags in nwfilters.
>
> It adds documentation to the web page and extends the tests as well.
>
> Signed-off-by: Stefan Berger
It would help to list a sample xml snippet in the commit message as
well, so that 'git log' can more easily find when it was introduced.
I haven't looked at this closely (it's post-0.9.0 material), but the
idea sounds nice and in line with your overall efforts of making
nwfilter more fine-grained :)
> +++ libvirt-acl/docs/formatnwfilter.html.in
> @@ -755,6 +755,11 @@
> STRING |
> comma separated list of NEW,ESTABLISHED,RELATED,INVALID or NONE |
>
> +
> + flags (Since 0.9.0) |
So this would need to be 0.9.1.
> + STRING |
> + TCP-only: format of mask/flags with mask and flags each being a
> comma separated list of SYN,ACK,URG,PSH,FIN,RST or NONE or ALL |
> +
>
>
>
> @@ -1040,6 +1045,11 @@
>
STRING |
> comma separated list of NEW,ESTABLISHED,RELATED,INVALID or NONE |
>
> +
> + flags (Since 0.8.5) |
Is 0.8.5 right?
> + STRING |
> + format of mask/flags with mask and flags each being a comma
> separated list of SYN,ACK,URG,PSH,FIN,RST or NONE or ALL |
> +
>
>
>
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From eblake at redhat.com Fri Apr 1 18:04:04 2011
From: eblake at redhat.com (Eric Blake)
Date: Fri, 01 Apr 2011 12:04:04 -0600
Subject: [libvirt] [PATCH] Fix several formatting mistakes in doc
In-Reply-To: <20110401012752.GH24385@redhat.com>
References: <1301570043-30978-1-git-send-email-mprivozn@redhat.com>
<20110331135837.GM24425@redhat.com> <4D94B6B6.7000806@redhat.com>
<20110331171843.GR24425@redhat.com> <4D94D495.4040503@redhat.com>
<20110401012752.GH24385@redhat.com>
Message-ID: <4D961394.4070204@redhat.com>
On 03/31/2011 07:27 PM, Daniel Veillard wrote:
>> $ SGML_CATALOG_FILES='/etc/xml/catalog' /usr/bin/xmllint --catalogs
>> --nonet --format --valid formatcaps.html.in >/dev/null
>> formatcaps.html.in:1: validity error : Validation failed: no DTD found !
>>
>> ^
>
> just drop --valid from the command line, xmllint usually doesn't
> check validity. But IMHO it's simpler to just drop the --html flag from
> xsltproc as suggestedon previous mail
Almost, it definitely caught some more bugs. But it's not perfect; now
I'm getting:
Generating csharp.html.tmp
csharp.html.in:21: parser error : Entity 'nbsp' not defined
^
...
csharp.html.in:125: parser error : Entity 'iacute' not defined
based upon the previous work of Jaromír Červenka.
^
when make tries:
name=`echo csharp.html.tmp | sed -e 's/.tmp//'`; \
/usr/bin/xsltproc --stringparam pagename $name --nonet \
../docs/site.xsl csharp.html.in > csharp.html.tmp
How do I make xsltproc recognize html entities without using --html?
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From matthias.bolte at googlemail.com Fri Apr 1 18:22:17 2011
From: matthias.bolte at googlemail.com (Matthias Bolte)
Date: Fri, 1 Apr 2011 20:22:17 +0200
Subject: [libvirt] [PATCH 1/6] virNodeGetCpuTime: Expose new API
In-Reply-To: <4D95FB08.20802@redhat.com>
References: <20110401103833.8b66b57e.usui@mxm.nes.nec.co.jp>
<20110401105548.a78607f7.usui@mxm.nes.nec.co.jp>
<4D95FB08.20802@redhat.com>
Message-ID:
2011/4/1 Eric Blake :
> On 03/31/2011 07:55 PM, Minoru Usui wrote:
>> virNodeGetCpuTime: Expose new API
>>
>> ?include/libvirt/libvirt.h.in | ? 26 ++++++++++++++++++++++++++
>> ?src/libvirt_public.syms ? ? ?| ? ?1 +
>> ?2 files changed, 27 insertions(+), 0 deletions(-)
>
>>
>> +/**
>> + * virNodeCpuTime:
>> + *
>> + * a virNodeCpuTime is a structure filled by virNodeGetCpuTime() and providing
>> + * the information for the cpu time of Node.
>> + */
>> +
>> +typedef struct _virNodeCpuTime virNodeCpuTime;
>> +
>> +struct _virNodeCpuTime {
>> + ? ?unsigned long long user;
>> + ? ?unsigned long long system;
>> + ? ?unsigned long long idle;
>> + ? ?unsigned long long iowait;
>> +};
>
> Can we portably get all of this information on Windows? ?If not, how do
> you express which values we don't know how to obtain?
>
In the context of ESX I vote against this absolute CPU time values.
ESX provides this values relative to a 20 second timeslots with 1 hour
of history. This makes it nearly impossible to obtain the absolute CPU
time. The same problem already exists for the domain's virtual CPU
time.
When you look at virt-top's usage of the domain's virtual CPU time,
you see that it actually doesn't really care about the absolute value,
but deduces the CPU utilization from it. I suggest that we find a
different representation for this information that is not by
definition impossible to implement for ESX.
Matthias
From stefanb at linux.vnet.ibm.com Fri Apr 1 19:47:09 2011
From: stefanb at linux.vnet.ibm.com (Stefan Berger)
Date: Fri, 01 Apr 2011 15:47:09 -0400
Subject: [libvirt] [PATCH] nwfilters: support for TCP flags evaluation
In-Reply-To: <4D96110E.4080907@redhat.com>
References: <4D95FA91.5080103@linux.vnet.ibm.com> <4D96110E.4080907@redhat.com>
Message-ID: <4D962BBD.8020904@linux.vnet.ibm.com>
On 04/01/2011 01:53 PM, Eric Blake wrote:
> On 04/01/2011 10:17 AM, Stefan Berger wrote:
>> This patch adds support for the evaluation of TCP flags in nwfilters.
>>
>> It adds documentation to the web page and extends the tests as well.
>>
>> Signed-off-by: Stefan Berger
> It would help to list a sample xml snippet in the commit message as
> well, so that 'git log' can more easily find when it was introduced.
>
Ok, I will add it in V2.
> I haven't looked at this closely (it's post-0.9.0 material), but the
> idea sounds nice and in line with your overall efforts of making
> nwfilter more fine-grained :)
Thanks.
>> +++ libvirt-acl/docs/formatnwfilter.html.in
>> @@ -755,6 +755,11 @@
>> STRING |
>> comma separated list of NEW,ESTABLISHED,RELATED,INVALID or NONE |
>>
>> +
>> +flags(Since 0.9.0) |
> So this would need to be 0.9.1.
Will fix it.
>> +STRING |
>> +TCP-only: format of mask/flags with mask and flags each being a
>> comma separated list of SYN,ACK,URG,PSH,FIN,RST or NONE or ALL |
>> +
>>
>>
>>
>> @@ -1040,6 +1045,11 @@
>>
STRING |
>> comma separated list of NEW,ESTABLISHED,RELATED,INVALID or NONE |
>>
>> +
>> +flags(Since 0.8.5) |
> Is 0.8.5 right?
Missed that one. That's how old this forgotten-about patch is...
Stefan
From eblake at redhat.com Fri Apr 1 22:04:52 2011
From: eblake at redhat.com (Eric Blake)
Date: Fri, 1 Apr 2011 16:04:52 -0600
Subject: [libvirt] [PATCH] docs: correct invalid xml
Message-ID: <1301695492-3876-1-git-send-email-eblake@redhat.com>
* docs/internals.html.in: Fix xml errors.
* docs/formatstorageencryption.html.in: Likewise.
* docs/drvesx.html.in: Likewise.
* docs/archnetwork.html.in: Likewise.
* docs/logging.html.in: Likewise.
* docs/drvvmware.html.in: Likewise.
* docs/api.html.in: Likewise.
* docs/formatnwfilter.html.in: Likewise.
* docs/formatdomain.html.in: Likewise.
* docs/windows.html.in: Likewise.
---
Tightening up xsltproc found all of these. I'm pushing under the
trivial rule.
docs/api.html.in | 11 ++--
docs/archnetwork.html.in | 2 +-
docs/drvesx.html.in | 10 ++--
docs/drvvmware.html.in | 4 +-
docs/formatdomain.html.in | 18 +++---
docs/formatnwfilter.html.in | 96 +++++++++++++++++-----------------
docs/formatstorageencryption.html.in | 2 +-
docs/internals.html.in | 4 +-
docs/logging.html.in | 4 +-
docs/windows.html.in | 12 ++--
10 files changed, 83 insertions(+), 80 deletions(-)
diff --git a/docs/api.html.in b/docs/api.html.in
index e8bbeed..384eb77 100644
--- a/docs/api.html.in
+++ b/docs/api.html.in
@@ -4,7 +4,7 @@
The libvirt API concepts
This page describes the main principles and architecture choices
- behind the definition of the libvirt API:
+ behind the definition of the libvirt API:
@@ -22,7 +22,7 @@
possible to use both KVM and LinuxContainers on the same node). A NULL
name will default to a preselected hypervisor but it's probably not a
wise thing to do in most cases. See the connection
- URI page for a full descriptions of the values allowed.
+ URI page for a full descriptions of the values allowed.
Once the application obtained a virConnectPtr
connection to the
hypervisor it can then use it to manage domains and related resources
@@ -61,7 +61,7 @@
defined
in which case they are inactive but there is
a permanent definition available in the system for them. Based on this
thay can be activated dynamically in order to be used.
- Most kind of object can also be named in various ways:
+
Most kind of object can also be named in various ways:
- by their
name
, an user friendly identifier but
whose unicity cannot be garanteed between two nodes.
@@ -82,7 +82,7 @@
For each first class object you will find apis
for the following actions:
- - Lookup:...LookupByName,
+
- Lookup:...LookupByName,
- Enumeration:virConnectList... and virConnectNumOf...:
those are used to enumerate a set of object available to an given
hypervisor connection like:
@@ -108,7 +108,8 @@
- Destruction: ...
For more in-depth details of the storage related APIs see
- the storage management page,
+ the storage management page.
+
diff --git a/docs/archnetwork.html.in b/docs/archnetwork.html.in
index 57b8f3d..c7ca4ca 100644
--- a/docs/archnetwork.html.in
+++ b/docs/archnetwork.html.in
@@ -32,7 +32,7 @@
- Guest C. The only network interface is connected
to a virtual network
VLAN 2
. It has no direct connectivity
- to a physical LAN, relying on Guest B
to route traffic
+ to a physical LAN, relying on Guest B
to route traffic
on its behalf.
diff --git a/docs/drvesx.html.in b/docs/drvesx.html.in
index a0f87c1..613cd07 100644
--- a/docs/drvesx.html.in
+++ b/docs/drvesx.html.in
@@ -74,7 +74,7 @@ vpx://example-vcenter.com/dc1/cluster1/example-esx.com
-
+
Extra parameters can be added to a URI as part of the query string
(the part following ?
). A single parameter is formed by a
@@ -308,7 +308,7 @@ error: invalid argument in libvirt was built without the 'esx' driver
There are several specialties in the domain XML config for ESX domains.
-
+
There are some restrictions for some values of the domain XML config.
The driver will complain if this restrictions are violated.
@@ -328,7 +328,7 @@ error: invalid argument in libvirt was built without the 'esx' driver
-
+
Storage is managed in datastores. VMware uses a special path format to
reference files in a datastore. Basically, the datastore name is put
@@ -347,7 +347,7 @@ error: invalid argument in libvirt was built without the 'esx' driver
-
+
VMware has registered two MAC address prefixes for domains:
00:0c:29
and 00:50:56
. These prefixes are
@@ -408,7 +408,7 @@ ethernet0.checkMACAddress = "false"
-
+
VMware ESX supports different models of SCSI controllers and network
cards.
diff --git a/docs/drvvmware.html.in b/docs/drvvmware.html.in
index 0ef6044..44814d3 100644
--- a/docs/drvvmware.html.in
+++ b/docs/drvvmware.html.in
@@ -8,7 +8,9 @@
This driver uses the "vmrun" utility which is distributed with the VMware VIX API.
- You can download the VIX API from here.
+ You can download the VIX API
+ from here.
+
Connections to VMware driver
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 5523fc7..6c624ab 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1277,7 +1277,7 @@
Provides direct attachment of the virtual machine's NIC to the given
physial interface of the host.
- Since 0.7.7 (QEMU and KVM only)
+ Since 0.7.7 (QEMU and KVM only)
This setup requires the Linux macvtap
driver to be available. (Since Linux 2.6.34.)
One of the modes 'vepa'
@@ -1299,7 +1299,7 @@
originate from are directly delivered to the target macvtap device.
Both origin and destination devices need to be in bridge mode
for direct delivery. If either one of them is in vepa
mode,
- a VEPA capable bridge is required.
+ a VEPA capable bridge is required.
private
All packets are sent to the external bridge and will only be
delivered to a target VM on the same host if they are sent through an
@@ -1488,23 +1488,23 @@ qemu-kvm -net nic,model=? /dev/null
The txmode
attribute specifies how to handle
transmission of packets when the transmit buffer is full. The
value can be either 'iothread' or 'timer'.
- Since 0.8.8 (QEMU and KVM only)
+ Since 0.8.8 (QEMU and KVM only)
If set to 'iothread', packet tx is all done in an iothread in
the bottom half of the driver (this option translates into
adding "tx=bh" to the qemu commandline -device virtio-net-pci
- option).
+ option).
If set to 'timer', tx work is done in qemu, and if there is
more tx data than can be sent at the present time, a timer is
set before qemu moves on to do other things; when the timer
- fires, another attempt is made to send more data.
+ fires, another attempt is made to send more data.
The resulting difference, according to the qemu developer who
added the option is: "bh makes tx more asynchronous and reduces
latency, but potentially causes more processor bandwidth
contention since the cpu doing the tx isn't necessarily the
- cpu where the guest generated the packets."
+ cpu where the guest generated the packets."
In general you should leave this option alone, unless you
are very certain you know what you are doing.
@@ -1628,8 +1628,8 @@ qemu-kvm -net nic,model=? /dev/null
in clear text. The keymap
attribute specifies the keymap
to use. It is possible to set a limit on the validity of the password
be giving an timestamp passwdValidTo='2010-04-09T15:51:00'
- assumed to be in UTC. NB, this may not be supported by all hypervisors.
-
+ assumed to be in UTC. NB, this may not be supported by all hypervisors.
+
Rather than using listen/port, QEMU supports a socket
attribute for listening on a unix domain socket path.
Since 0.8.8
@@ -2103,7 +2103,7 @@ qemu-kvm -net nic,model=? /dev/null
Alternatively you can use telnet
instead of raw
TCP.
Since 0.8.5 you can also use telnets
(secure telnet) and tls
.
-
+
...
diff --git a/docs/formatnwfilter.html.in b/docs/formatnwfilter.html.in
index 8840856..eb3c72b 100644
--- a/docs/formatnwfilter.html.in
+++ b/docs/formatnwfilter.html.in
@@ -25,18 +25,18 @@
cannot be circumvented from within
the virtual machine, it makes them mandatory from the point of
view of a virtual machine user.
-
+
The network filter subsystem allows each virtual machine's network
traffic filtering rules to be configured individually on a per
interface basis. The rules are
applied on the host when the virtual machine is started and can be modified
while the virtual machine is running. The latter can be achieved by
modifying the XML description of a network filter.
-
+
Multiple virtual machines can make use of the same generic network filter.
When such a filter is modified, the network traffic filtering rules
of all running virtual machines that reference this filter are updated.
-
+
Network filtering support is available since 0.8.1
(Qemu, KVM)
@@ -79,7 +79,7 @@
other filters can be used, a tree of filters can be built.
The clean-traffic
filter can be viewed using the
command virsh nwfilter-dumpxml clean-traffic
.
-
+
As previously mentioned, a single network filter can be referenced
by multiple virtual machines. Since interfaces will typically
have individual parameters associated with their respective traffic
@@ -108,7 +108,7 @@
10.0.0.1 and enforce that the traffic from this interface will
always be using 10.0.0.1 as the source IP address, which is
one of the purposes of this particular filter.
-
+
@@ -117,7 +117,7 @@
Two variables names have so far been reserved for usage by the
network traffic filtering subsystem: MAC
and
IP
.
-
+
MAC
is the MAC address of the
network interface. A filtering rule that references this variable
will automatically be instantiated with the MAC address of the
@@ -125,7 +125,7 @@
the MAC parameter. Even though it is possible to specify the MAC
parameter similar to the IP parameter above, it is discouraged
since libvirt knows what MAC address an interface will be using.
-
+
The parameter IP
represents the IP address
that the operating system inside the virtual machine is expected
to use on the given interface. The IP
parameter
@@ -136,7 +136,7 @@
For current limitations on IP address detection, consult the
section on limitations on how to use this
feature and what to expect when using it.
-
+
The following is the XML description of the network filer
no-arp-spoofing
. It serves as an example for
a network filter XML referencing the MAC
and
@@ -205,7 +205,7 @@
filters may be referenced multiple times in a filter tree but
references between filters must not introduce loops (directed
acyclic graph).
-
+
The following shows the XML of the clean-traffic
network filter referencing several other filters.
@@ -226,7 +226,7 @@
needs to be provided inside a filter
node. This
node must have the attribute filter
whose value contains
the name of the filter to be referenced.
-
+
New network filters can be defined at any time and
may contain references to network filters that are
not known to libvirt, yet. However, once a virtual machine
@@ -282,7 +282,7 @@
statematch -- optional; possible values are '0' or 'false' to
turn the underlying connection state matching off; default is 'true'
-
+
Also read the section on advanced configuration
topics.
@@ -294,7 +294,7 @@
traffic of type ip
is also associated with the chain
'ipv4' then that filter's rules will be ordered relative to the priority
500 of the shown rule.
-
+
A rule may contain a single rule for filtering of traffic. The
above example shows that traffic of type ip
is to be
filtered.
@@ -325,7 +325,7 @@
STRING: A string
-
+
Every attribute except for those of type IP_MASK or IPV6_MASK can
be negated using the match
attribute with value no
. Multiple negated attributes
@@ -349,14 +349,14 @@
the protocol property attribute1 does not match value1 AND
the protocol property attribute2 does not match value2 AND
the protocol property attribute3 matches value3.
-
+
Protocol ID: mac
-
+
Note: Rules of this type should go into the root
chain.
@@ -408,7 +408,7 @@
Protocol ID: arp
or rarp
-
+
Note: Rules of this type should either go into the
root
or arp/rarp
chain.
@@ -483,7 +483,7 @@
Valid strings for the Opcode
field are:
Request, Reply, Request_Reverse, Reply_Reverse, DRARP_Request,
DRARP_Reply, DRARP_Error, InARP_Request, ARP_NAK
-
+
@@ -572,7 +572,7 @@
Valid strings for protocol
are:
tcp, udp, udplite, esp, ah, icmp, igmp, sctp
-
+
@@ -662,13 +662,13 @@
Valid strings for protocol
are:
tcp, udp, udplite, esp, ah, icmpv6, sctp
-
+
Protocol ID: tcp
, udp
, sctp
-
+
Note: The chain parameter is ignored for this type of traffic
and should either be omitted or set to root
.
@@ -757,14 +757,14 @@
-
+
Protocol ID: icmp
-
+
Note: The chain parameter is ignored for this type of traffic
and should either be omitted or set to root
.
@@ -857,13 +857,13 @@
-
+
Protocol ID: igmp
, esp
, ah
, udplite
, all
-
+
Note: The chain parameter is ignored for this type of traffic
and should either be omitted or set to root
.
@@ -946,14 +946,14 @@
-
+
Protocol ID: tcp-ipv6
, udp-ipv6
, sctp-ipv6
-
+
Note: The chain parameter is ignored for this type of traffic
and should either be omitted or set to root
.
@@ -1042,14 +1042,14 @@
-
+
Protocol ID: icmpv6
-
+
Note: The chain parameter is ignored for this type of traffic
and should either be omitted or set to root
.
@@ -1128,13 +1128,13 @@
-
+
Protocol ID: igmp-ipv6
, esp-ipv6
, ah-ipv6
, udplite-ipv6
, all-ipv6
-
+
Note: The chain parameter is ignored for this type of traffic
and should either be omitted or set to root
.
@@ -1202,7 +1202,7 @@
-
+
@@ -1227,7 +1227,7 @@
port 80 on an attacker site, then the attacker will not be able to
initiate a connection from TCP port 80 back towards the VM.
By default the connection state match that enables connection tracking
- and then enforcement of directionality of traffic is turned on.
+ and then enforcement of directionality of traffic is turned on.
The following shows an example XML fragement where this feature has been
turned off for incoming connections to TCP port 12345.
@@ -1277,14 +1277,14 @@
Note that the rule for the limit has to logically appear
- before the rule for accepting the traffic.
+ before the rule for accepting the traffic.
An additional rule for letting DNS traffic to port 22
go out the VM has been added to avoid ssh sessions not
getting established for reasons related to DNS lookup failures
by the ssh daemon. Leaving this rule out may otherwise lead to
fun-filled debugging joy (symptom: ssh client seems to hang
while trying to connect).
-
+
Lot of care must be taken with timeouts related
to tracking of traffic. An ICMP ping that
the user may have terminated inside the VM may have a long
@@ -1299,7 +1299,7 @@
sets the ICMP connection tracking timeout to 3 seconds. The
effect of this is that once one ping is terminated, another
- one can start after 3 seconds.
+ one can start after 3 seconds.
Further, we want to point out that a client that for whatever
reason has not properly closed a TCP connection may cause a
connection to be held open for a longer period of time,
@@ -1323,7 +1323,7 @@
with life-cycle support for network filters. All commands related
to the network filtering subsystem start with the prefix
nwfilter
. The following commands are available:
-
+
- nwfilter-list : list UUIDs and names of all network filters
- nwfilter-define : define a new network filter or update an existing one
@@ -1398,7 +1398,7 @@
the protocols very well that you want to be filtering on so that
no further traffic than what you want can pass and that in fact the
traffic you want to allow does pass.
-
+
The network filtering subsystem is currently only available on
Linux hosts and only works for Qemu and KVM type of virtual machines.
On Linux
@@ -1412,19 +1412,19 @@
- arp, rarp
- ip
- ipv6
-
+
All other protocols over IPv4 are supported using iptables, those over
IPv6 are implemented using ip6tables.
-
+
On a Linux host, all traffic filtering instantiated by libvirt's network
filter subsystem first passes through the filtering support implemented
by ebtables and only then through iptables or ip6tables filters. If
a filter tree has rules with the protocols mac
,
arp
, rarp
, ip
, or ipv6
ebtables rules will automatically be instantiated.
-
+
The role of the chain
attribute in the network filter
XML is that internally a new user-defined ebtables table is created
that then for example receives all arp
traffic coming
@@ -1435,7 +1435,7 @@
placed into filters specifying this chain. This type of branching
into user-defined tables is only supported with filtering on the ebtables
layer.
-
+
As an example, it is
possible to filter on UDP traffic by source and destination ports using
the ip
protocol filter and specifying attributes for the
@@ -1467,7 +1467,7 @@
The requirement to prevent spoofing is fulfilled by the existing
clean-traffic
network filter, thus we will reference this
filter from our custom filter.
-
+
To enable traffic for TCP ports 22 and 80 we will add 2 rules to
enable this type of traffic. To allow the VM to send ping traffic
we will add a rule for ICMP traffic. For simplicity reasons
@@ -1523,7 +1523,7 @@
per-interface basis and the rules are evaluated based on the knowledge
about which (tap) interface has sent or will receive the packet rather
than what their source or destination IP address may be.
-
+
An XML fragment for a possible network interface description inside
the domain XML of the test
VM could then look like this:
@@ -1568,7 +1568,7 @@
allows the VM to send ping traffic from an interface
but not let the VM be pinged on the interface
allows the VM to do DNS lookups (UDP towards port 53)
- enable an ftp server (in active mode) to be run inside the VM
+ enable an ftp server (in active mode) to be run inside the VM
The additional requirement of allowing an ftp server to be run inside
@@ -1577,7 +1577,7 @@
outgoing tcp connection originating from the VM's TCP port 20 back to
the ftp client (ftp active mode). There are several ways of how this
filter can be written and we present 2 solutions.
-
+
The 1st solution makes use of the state
attribute of
the TCP protocol that gives us a hook into the connection tracking
framework of the Linux host. For the VM-initiated ftp data connection
@@ -1752,13 +1752,13 @@
to be using.
Different IP addresses in use by multiple interfaces of a VM
(one IP address each) will be independently detected.
-
+
Once a VM's IP address has been detected, its IP network traffic
may be locked to that address, if for example IP address spoofing
is prevented by one of its filters. In that case the user of the VM
will not be able to change the IP address on the interface inside
the VM, which would be considered IP address spoofing.
-
+
In case a VM is resumed after suspension or migrated, IP address
detection will be restarted.
@@ -1776,7 +1776,7 @@
outside the scope of libvirt to ensure that referenced filters
on the source system are equivalent to those on the target system
and vice versa.
-
+
Migration must occur between libvirt insallations of version
0.8.1 or later in order not to lose the network traffic filters
associated with an interface.
diff --git a/docs/formatstorageencryption.html.in b/docs/formatstorageencryption.html.in
index 0e5dcee..9557a22 100644
--- a/docs/formatstorageencryption.html.in
+++ b/docs/formatstorageencryption.html.in
@@ -30,7 +30,7 @@
by the particular volume format and driver, automatically generate a
secret value at the time of volume creation, and store it using the
specified uuid
.
-
+
<encryption type="default"/>
can be specified only
diff --git a/docs/internals.html.in b/docs/internals.html.in
index 6fa2de3..5689998 100644
--- a/docs/internals.html.in
+++ b/docs/internals.html.in
@@ -9,9 +9,9 @@
diff --git a/docs/logging.html.in b/docs/logging.html.in
index 44171de..ebacdac 100644
--- a/docs/logging.html.in
+++ b/docs/logging.html.in
@@ -82,7 +82,7 @@
Logging in the daemon
Similarly the daemon logging behaviour can be tuned using 3 config
- variables, stored in the configuration file:
+ variables, stored in the configuration file:
- log_level: accepts the following values:
@@ -128,7 +128,7 @@
Multiple filters can be defined in a single string, they just need to be
separated by spaces, e.g: "3:remote 4:event"
to only get
warning or errors from the remote layer and only errors from the event
- layer.
+ layer.
If you specify a log priority in a filter that is below the default log
priority level, messages that match that filter will still be logged,
while others will not. In order to see those messages, you must also have
diff --git a/docs/windows.html.in b/docs/windows.html.in
index 4011cc3..8e0af7c 100644
--- a/docs/windows.html.in
+++ b/docs/windows.html.in
@@ -30,7 +30,7 @@
and untested Python bindings.
-
+
-
These are problems we know about, and need to be fixed in subsequent
@@ -72,7 +72,7 @@
- Connection types
+ Connection types
These connection types are known to work:
@@ -114,7 +114,7 @@
be used in security sensitive environments.
- Connecting to VMware ESX/vSphere
+ Connecting to VMware ESX/vSphere
Details on the capabilities, certificates, and connection string
@@ -124,7 +124,7 @@
http://libvirt.org/drvesx.html
-
TLS Certificates
+ TLS Certificates
TLS certificates need to have been created and placed in the correct
@@ -184,7 +184,7 @@
- C:\Users\someuser\AppData\Roaming\libvirt\pki\libvirt\private\clientkey.pem
- Feedback
+ Feedback
Feedback and suggestions on changes to make and what else to include
--
1.7.4
From eblake at redhat.com Fri Apr 1 22:06:50 2011
From: eblake at redhat.com (Eric Blake)
Date: Fri, 1 Apr 2011 16:06:50 -0600
Subject: [libvirt] [RFC PATCH] build: detect doc build errors
Message-ID: <1301695610-4003-1-git-send-email-eblake@redhat.com>
I'm still stumped by xsltproc complaining about not being a
valid XML entity, hence the (hackish) exemption in docs/Makefile.am
that adds --html for a couple of .html.in files. But for the
remaining files, this does make input validation stricter, and caught
several bugs.
Hence, this is an RFC (either we live with my hack that caught
all the issues in the prior patch, or someone with more xsltproc
knowledge than me will step in and teach it how to resolve html
entities while processing the documents as xml instead of html).
* docs/Makefile.am (maintainer-clean-local): Remove generated docs
in VPATH build.
(%.html.tmp): Don't use looser --html; our input should be strict
xhtml. HACK - use --html when entities like are involved.
(html/index.html): Exit on formatting problems.
(rebuild): Run full doc build on request.
---
docs/Makefile.am | 24 ++++++++++++++----------
1 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/docs/Makefile.am b/docs/Makefile.am
index db4bc59..2d1afe4 100644
--- a/docs/Makefile.am
+++ b/docs/Makefile.am
@@ -123,7 +123,7 @@ internals/%.html.tmp: internals/%.html.in subsite.xsl page.xsl sitemap.html.in
echo "Generating $@"; \
$(MKDIR_P) "$(builddir)/internals"; \
name=`echo $@ | sed -e 's/.tmp//'`; \
- $(XSLTPROC) --stringparam pagename $$name --nonet --html \
+ $(XSLTPROC) --stringparam pagename $$name --nonet \
$(top_srcdir)/docs/subsite.xsl $< > $@ \
|| { rm $@ && exit 1; }; fi
@@ -131,7 +131,8 @@ internals/%.html.tmp: internals/%.html.in subsite.xsl page.xsl sitemap.html.in
@if [ -x $(XSLTPROC) ] ; then \
echo "Generating $@"; \
name=`echo $@ | sed -e 's/.tmp//'`; \
- $(XSLTPROC) --stringparam pagename $$name --nonet --html \
+ $(XSLTPROC) --stringparam pagename $$name --nonet \
+ $$(grep -qE '&(nbsp|uuml|mdash);' $< && printf %s --html) \
$(top_srcdir)/docs/site.xsl $< > $@ \
|| { rm $@ && exit 1; }; fi
@@ -147,21 +148,22 @@ internals/%.html.tmp: internals/%.html.in subsite.xsl page.xsl sitemap.html.in
html/index.html: libvirt-api.xml newapi.xsl page.xsl sitemap.html.in
- - at if [ -x $(XSLTPROC) ] ; then \
+ @if [ -x $(XSLTPROC) ] ; then \
echo "Rebuilding the HTML pages from the XML API" ; \
$(XSLTPROC) --nonet -o $(srcdir)/ \
$(srcdir)/newapi.xsl $(srcdir)/libvirt-api.xml ; fi
- - at if test -x $(XMLLINT) && test -x $(XMLCATALOG) ; then \
- if $(XMLCATALOG) '$(XML_CATALOG_FILE)' "-//W3C//DTD XHTML 1.0 Strict//EN" \
- > /dev/null ; then \
+ @if test -x $(XMLLINT) && test -x $(XMLCATALOG) ; then \
+ if $(XMLCATALOG) '$(XML_CATALOG_FILE)' \
+ "-//W3C//DTD XHTML 1.0 Strict//EN" > /dev/null ; then \
echo "Validating the resulting XHTML pages" ; \
SGML_CATALOG_FILES='$(XML_CATALOG_FILE)' \
- $(XMLLINT) --catalogs --nonet --valid --noout $(srcdir)/html/*.html ; \
+ $(XMLLINT) --catalogs --nonet --valid --noout $(srcdir)/html/*.html \
+ || { rm $(srcdir)/$@ && exit 1; }; \
else echo "missing XHTML1 DTD" ; fi ; fi
$(addprefix $(srcdir)/,$(devhelphtml)): $(srcdir)/libvirt-api.xml $(devhelpxsl)
- at echo Rebuilding devhelp files
- - at if [ -x $(XSLTPROC) ] ; then \
+ @if [ -x $(XSLTPROC) ] ; then \
$(XSLTPROC) --nonet -o $(srcdir)/devhelp/ \
$(top_srcdir)/docs/devhelp/devhelp.xsl $(srcdir)/libvirt-api.xml ; fi
@@ -183,9 +185,11 @@ clean-local:
rm -f *~ *.bak *.hierarchy *.signals *-unused.txt *.html
maintainer-clean-local: clean-local
- rm -rf $(srcdir)/libvirt-api.xml $(srcdir)/libvirt-refs.xml todo.html.in
+ rm -rf $(srcdir)/libvirt-api.xml $(srcdir)/libvirt-refs.xml \
+ todo.html.in $(srcdir)/*.html $(srcdir)/devhelp/*.html \
+ $(srcdir)/html/*.html $(srcdir)/internals/*.html
-rebuild: api all
+rebuild: maintainer-clean-local api all
install-data-local:
$(mkinstalldirs) $(DESTDIR)$(HTML_DIR)
--
1.7.4
From eblake at redhat.com Fri Apr 1 22:18:53 2011
From: eblake at redhat.com (Eric Blake)
Date: Fri, 1 Apr 2011 16:18:53 -0600
Subject: [libvirt] [PATCH] docs: fix typo
Message-ID: <1301696333-1914-1-git-send-email-eblake@redhat.com>
* docs/formatdomain.html.in: Fix KVM name.
---
Pushing under the trivial rule.
docs/formatdomain.html.in | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 6c624ab..574fee5 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -314,7 +314,7 @@
memtune
The optional memtune
element provides details
regarding the memory tunable parameters for the domain. If this is
- omitted, it defaults to the OS provided defaults. For QEMU/KVMi, the
+ omitted, it defaults to the OS provided defaults. For QEMU/KVM, the
parameters are applied to the QEMU process as a whole. Thus, when
counting them, one needs to add up guest RAM, guest video RAM, and
some memory overhead of QEMU itself. The last piece is hard to
--
1.7.4
From liyong at skybility.com Sat Apr 2 03:20:30 2011
From: liyong at skybility.com (Lyre)
Date: Sat, 2 Apr 2011 11:20:30 +0800
Subject: [libvirt] [libvirt-php] Fixed set_error when argument is NULL
Message-ID: <1301714430-9304-1-git-send-email-liyong@skybility.com>
Avoid freeing a NULL pointer
---
src/libvirt-php.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/libvirt-php.c b/src/libvirt-php.c
index 6a76f45..66b1de9 100644
--- a/src/libvirt-php.c
+++ b/src/libvirt-php.c
@@ -237,12 +237,16 @@ PHP_MINFO_FUNCTION(libvirt)
*/
void set_error(char *msg TSRMLS_DC)
{
- if (msg == NULL) {
+ if (LIBVIRT_G (last_error) != NULL)
+ {
efree(LIBVIRT_G (last_error));
+ }
+
+ if (msg == NULL) {
+ LIBVIRT_G (last_error) = NULL;
return;
}
php_error_docref(NULL TSRMLS_CC, E_WARNING,"%s",msg);
- if (LIBVIRT_G (last_error)!=NULL) efree(LIBVIRT_G (last_error));
LIBVIRT_G (last_error)=estrndup(msg,strlen(msg));
}
--
1.7.3.4
?
From veillard at redhat.com Sat Apr 2 05:45:46 2011
From: veillard at redhat.com (Daniel Veillard)
Date: Sat, 2 Apr 2011 13:45:46 +0800
Subject: [libvirt] [PATCH] Fix several formatting mistakes in doc
In-Reply-To: <4D961394.4070204@redhat.com>
References: <1301570043-30978-1-git-send-email-mprivozn@redhat.com>
<20110331135837.GM24425@redhat.com> <4D94B6B6.7000806@redhat.com>
<20110331171843.GR24425@redhat.com> <4D94D495.4040503@redhat.com>
<20110401012752.GH24385@redhat.com> <4D961394.4070204@redhat.com>
Message-ID: <20110402054546.GN24385@redhat.com>
On Fri, Apr 01, 2011 at 12:04:04PM -0600, Eric Blake wrote:
> On 03/31/2011 07:27 PM, Daniel Veillard wrote:
> >> $ SGML_CATALOG_FILES='/etc/xml/catalog' /usr/bin/xmllint --catalogs
> >> --nonet --format --valid formatcaps.html.in >/dev/null
> >> formatcaps.html.in:1: validity error : Validation failed: no DTD found !
> >>
> >> ^
> >
> > just drop --valid from the command line, xmllint usually doesn't
> > check validity. But IMHO it's simpler to just drop the --html flag from
> > xsltproc as suggestedon previous mail
>
> Almost, it definitely caught some more bugs. But it's not perfect; now
> I'm getting:
>
> Generating csharp.html.tmp
> csharp.html.in:21: parser error : Entity 'nbsp' not defined
>
> ^
> ...
> csharp.html.in:125: parser error : Entity 'iacute' not defined
> based upon the previous work of Jaromír Červenka.
> ^
Ah, that normal, it's an error but not a fatal error, the nbsp
entity is available from the DTD but since we didn't asked for
validation libxml2 didn't try to fetch it. Note it's an error, not
a fatal error, i.e. processing continues, as the prser can't guess
if the entity was in the (not loaded) DTD or not.
You can add the --loaddtd to xmllint command line to ask it to
load the DTd while just checking the well-formedness of the document
> when make tries:
>
> name=`echo csharp.html.tmp | sed -e 's/.tmp//'`; \
> /usr/bin/xsltproc --stringparam pagename $name --nonet \
> ../docs/site.xsl csharp.html.in > csharp.html.tmp
>
> How do I make xsltproc recognize html entities without using --html?
xsltproc will load the DTD, so there should be no problem there.
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel at veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
From matthias.bolte at googlemail.com Sat Apr 2 06:15:13 2011
From: matthias.bolte at googlemail.com (Matthias Bolte)
Date: Sat, 2 Apr 2011 08:15:13 +0200
Subject: [libvirt] [PATCH] build: detect potentential uninitialized
variables
In-Reply-To: <1301673022-7410-1-git-send-email-eblake@redhat.com>
References: <1301673022-7410-1-git-send-email-eblake@redhat.com>
Message-ID:
2011/4/1 Eric Blake :
> Even with -Wuninitialized (which is part of autobuild.sh
> --enable-compile-warnings=error), gcc does NOT catch this
> use of an uninitialized variable:
>
> {
> ?if (cond)
> ? ?goto error;
> ?int a = 1;
> error:
> ?printf("%d", a);
> }
>
> which prints 0 (if the stack was previously wiped) if cond
> was true. ?Clang will catch it, but we dont' use clang as
> often. ?Using gcc -Wjump-misses-init gives false positives:
>
> {
> ?if (cond)
> ? ?goto error;
> ?int a = 1;
> ?return a;
> error:
> ?return 0;
> }
>
> Here, a was never used in the scope of the error block, so
> declaring it after goto is technically fine (and clang agrees);
> however, given that our HACKING already documents a preference
> to C89 decl-before-statement, the false positive warning is
> enough of a prod to comply with HACKING.
>
> [Personally, I'd _really_ rather use C99 decl-after-statement
> to minimize scope, but until gcc can efficiently and reliably
> catch scoping and uninitialized usage bugs, I'll settle with
> the compromise of enforcing a coding standard that rejects
> false positives.]
> diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
> index 9082515..b03f774 100644
> --- a/src/qemu/qemu_hotplug.c
> +++ b/src/qemu/qemu_hotplug.c
> @@ -51,8 +51,8 @@ int qemuDomainChangeEjectableMedia(struct qemud_driver *driver,
> ? ? int i;
> ? ? int ret;
> ? ? char *driveAlias = NULL;
> + ? ?qemuDomainObjPrivatePtr priv;
>
> - ? ?origdisk = NULL;
> ? ? for (i = 0 ; i < vm->def->ndisks ; i++) {
> ? ? ? ? if (vm->def->disks[i]->bus == disk->bus &&
> ? ? ? ? ? ? STREQ(vm->def->disks[i]->dst, disk->dst)) {
I had to look it up in the source, as it is not visible in the context
that it's okay to remove origdisk = NULL, but origdisk is already
initialized to NULL, so this second assignment is not necessary.
ACK.
Matthias
From matthias.bolte at googlemail.com Sat Apr 2 07:34:07 2011
From: matthias.bolte at googlemail.com (Matthias Bolte)
Date: Sat, 2 Apr 2011 09:34:07 +0200
Subject: [libvirt] [Libvirt-announce] 0.9.0 freeze week,
RC2 version to test
In-Reply-To: <305053C1-65ED-4BCA-99CF-15927F4B31E9@redhat.com>
References: <20110328062538.GB7346@redhat.com>
<20110329144659.GD25888@redhat.com>
<20110331134423.GK24425@redhat.com>
<305053C1-65ED-4BCA-99CF-15927F4B31E9@redhat.com>
Message-ID:
2011/3/31 Justin Clift :
> On 01/04/2011, at 12:44 AM, Daniel P. Berrange wrote:
>> On Wed, Mar 30, 2011 at 02:16:28AM +1100, Justin Clift wrote:
>
>>> Same problem with virsh on OSX. ?Straight out hangs and never gets
>>> to the prompt.
>>
>> Please run virsh with ?LIBVIRT_DEBUG=1 set and capture the logs.
>>
>> Also when it hangs please capture a full stack trace showing
>> where it has got stuck
>
> Thanks. ?It's looking like some kind of problem interacting with
> VirtualBox (v4.0.4):
> This is the full gdb backtrace from the process:
>
> ?(gdb) thread apply all bt
>
> ?Thread 1 (process 85784):
> ?#0 ?0x00007fff8549b3a6 in swtch_pri ()
> ?#1 ?0x00007fff854d5b51 in _pthread_find_thread ()
> ?#2 ?0x00007fff8551cb3e in pthread_getschedparam ()
> ?#3 ?0x00000001013c8752 in PR_SetThreadPriority ()
> ?#4 ?0x00000001013c88f1 in _PR_InitThreads ()
> ?#5 ?0x00000001013bbc26 in _PR_ImplicitInitialization ()
> ?#6 ?0x00000001013c8916 in PR_GetCurrentThread ()
> ?#7 ?0x00000001013a048f in nsIThread::GetCurrent ()
> ?#8 ?0x00000001013a04c1 in nsIThread::SetMainThread ()
> ?#9 ?0x00000001013524ee in NS_InitXPCOM2 ()
> ?#10 0x00000001004c022a in com::Initialize ()
> ?#11 0x00000001004bef8f in VBoxComInitialize ()
> ?#12 0x000000010015fa7f in vboxInitialize ()
> ?#13 0x0000000100160039 in vboxOpen ()
> ?#14 0x00000001000abbcb in do_open ()
> ?#15 0x00000001000ac712 in virConnectOpenAuth ()
> ?#16 0x000000010001a7ef in vshInit ()
> ?#17 0x000000010001bef1 in main ()
> ?(gdb)
>
> Any of that helpful?
Strange point to get stuck.
I assume VirtualBox for OSX comes with it's own GUI tool. Is it also
affected or only virsh?
Does this happen with VirtualBox 4.0.4 only, or is 4.x or even 3.x affected too?
Matthias
From matthias.bolte at googlemail.com Sat Apr 2 07:38:54 2011
From: matthias.bolte at googlemail.com (Matthias Bolte)
Date: Sat, 2 Apr 2011 09:38:54 +0200
Subject: [libvirt] mingw: virsh event loop failure in current git
In-Reply-To: <4D950D60.6060104@redhat.com>
References:
<4D950D60.6060104@redhat.com>
Message-ID:
2011/4/1 Eric Blake :
> On 03/15/2011 02:29 AM, Matthias Bolte wrote:
>> Commit 2ed6cc7bec41dd344d41ea1531f6760c93099128 "Expose event loop
>> implementation as a public API" turned a failure to initialize the
>> default event loop into a fatal error in virsh on Windows. Before that
>> commit such a failure was ignored.
>
> Does this patch fix things? ?If so, we should definitely get it into 0.9.0:
> https://www.redhat.com/archives/libvir-list/2011-March/msg01553.html
>
> (but be sure to pick up the logic correction before testing):
> https://www.redhat.com/archives/libvir-list/2011-March/msg01554.html
>
Yes, at least virSetNonBlock doesn't fail anymore. But now
virSetCloseExec is the next thing that fails, because it calls
virSetInherit and virSetInherit always returns -1 on Windows.
Matthias
From wencongyang at gmail.com Sun Apr 3 01:16:43 2011
From: wencongyang at gmail.com (Wen Congyang)
Date: Sun, 03 Apr 2011 09:16:43 +0800
Subject: [libvirt] [PATCH] do not lock vm while allocating memory
In-Reply-To: <4D95FC55.8080800@redhat.com>
References: <4D92DFD9.6000700@cn.fujitsu.com> <4D95FC55.8080800@redhat.com>
Message-ID: <4D97CA7B.4040108@gmail.com>
? 2011-4-2 0:24, Eric Blake ??:
> On 03/30/2011 01:46 AM, Wen Congyang wrote:
>> There is no need to lock vm while allocating memory. If allocating
>> memory failed, we forgot to unlock vm.
>>
>> ---
>> src/qemu/qemu_process.c | 3 +--
>> 1 files changed, 1 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
>> index e31e1b4..e74e0f1 100644
>> --- a/src/qemu/qemu_process.c
>> +++ b/src/qemu/qemu_process.c
>> @@ -525,8 +525,6 @@ qemuProcessHandleGraphics(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
>> virDomainEventGraphicsSubjectPtr subject = NULL;
>> int i;
>>
>> - virDomainObjLock(vm);
>> -
>> if (VIR_ALLOC(localAddr)< 0)
>> goto no_memory;
>> localAddr->family = localFamily;
>> @@ -560,6 +558,7 @@ qemuProcessHandleGraphics(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
>> subject->nidentity++;
>> }
>>
>> + virDomainObjLock(vm);
>
> ACK. It only affects the OOM path, but is worth including in 0.9.0.
Thanks, pushed.
>
>
>
>
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
From wencongyang at gmail.com Sun Apr 3 01:18:23 2011
From: wencongyang at gmail.com (Wen Congyang)
Date: Sun, 03 Apr 2011 09:18:23 +0800
Subject: [libvirt] [PATCH] fix memory leak in qemuProcessHandleGraphics()
In-Reply-To: <4D95FCA7.3070801@redhat.com>
References: <4D92DFE1.4070602@cn.fujitsu.com> <4D95FCA7.3070801@redhat.com>
Message-ID: <4D97CADF.2080006@gmail.com>
? 2011-4-2 0:26, Eric Blake ??:
> On 03/30/2011 01:46 AM, Wen Congyang wrote:
>> If strdup("x509dname") or strdup("saslUsername") success, but
>> strdup(x509dname) or strdup(saslUsername) failed, subject->nidentity
>> is not the num elements of subject->identities, and we will leak some
>> memory.
>>
>> ---
>> src/qemu/qemu_process.c | 12 ++++++------
>> 1 files changed, 6 insertions(+), 6 deletions(-)
>
> ACK - another OOM-only error appropriate for 0.9.0. I'm guessing you
> found it by inspection?
Yes, I found it by inspection.
I pushed this patch, thanks.
>
>
>
>
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
From mcastrol at gmail.com Sun Apr 3 08:43:45 2011
From: mcastrol at gmail.com (=?ISO-8859-1?Q?Marcela_Castro_Le=F3n?=)
Date: Sun, 3 Apr 2011 10:43:45 +0200
Subject: [libvirt] Using Restore in another host.
Message-ID:
Hello:
I need to know if I can use the restore operation (virsh o the equivalent in
libvirt) to recover a previous state of a guest, but recovered previously in
another host.
I did a test, but I got an error:
The exactly sequence using virsh I testes is:
On [HOST SOURCE]: Using virsh
1) save [domain] [file]
2) restore file
3) destroy [domain]
On [HOST SOURCE] using ubuntu sh
4) cp [guest.img] [guest.xml] [file] to HOST2
On [HOST TARGET] using virsh
5) define [guest.xml] (using image on destination in HOST2)
6) restore [file]
The restore troughs the following message:
*virsh # restore sv-chubut-2011-04-01-09:58
error: Failed to restore domain from sv-chubut-2011-04-01-09:58
error: monitor socket did not show up.: Connection refused*
Thank you very much.
Marcela.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From matthias.bolte at googlemail.com Sun Apr 3 09:21:14 2011
From: matthias.bolte at googlemail.com (Matthias Bolte)
Date: Sun, 3 Apr 2011 11:21:14 +0200
Subject: [libvirt] [PATCH 01/20] Remove PATH_MAX sized stack allocations
related to virFileBuildPath
In-Reply-To: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <1301822493-23013-2-git-send-email-matthias.bolte@googlemail.com>
Make virFileBuildPath operate on the heap instead of the stack. It
allocates a buffer instead of expecting a preexisting buffer.
---
src/conf/nwfilter_conf.c | 21 +++++++--------------
src/conf/storage_conf.c | 44 +++++++++++++++-----------------------------
src/util/util.c | 29 +++++++++++++++--------------
src/util/util.h | 8 +++-----
src/xen/xen_inotify.c | 16 +++++++++-------
src/xen/xm_internal.c | 33 +++++++++++++++++----------------
6 files changed, 66 insertions(+), 85 deletions(-)
diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c
index 13b5b38..df8e20f 100644
--- a/src/conf/nwfilter_conf.c
+++ b/src/conf/nwfilter_conf.c
@@ -2484,7 +2484,7 @@ virNWFilterLoadAllConfigs(virConnectPtr conn,
}
while ((entry = readdir(dir))) {
- char path[PATH_MAX];
+ char *path;
virNWFilterObjPtr nwfilter;
if (entry->d_name[0] == '.')
@@ -2493,17 +2493,16 @@ virNWFilterLoadAllConfigs(virConnectPtr conn,
if (!virFileHasSuffix(entry->d_name, ".xml"))
continue;
- if (virFileBuildPath(configDir, entry->d_name,
- NULL, path, PATH_MAX) < 0) {
- virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
- _("config filename '%s/%s' is too long"),
- configDir, entry->d_name);
+ if (!(path = virFileBuildPath(configDir, entry->d_name, NULL))) {
+ virReportOOMError();
continue;
}
nwfilter = virNWFilterObjLoad(conn, nwfilters, entry->d_name, path);
if (nwfilter)
virNWFilterObjUnlock(nwfilter);
+
+ VIR_FREE(path);
}
closedir(dir);
@@ -2523,7 +2522,6 @@ virNWFilterObjSaveDef(virNWFilterDriverStatePtr driver,
if (!nwfilter->configFile) {
int err;
- char path[PATH_MAX];
if ((err = virFileMakePath(driver->configDir))) {
virReportSystemError(err,
@@ -2532,13 +2530,8 @@ virNWFilterObjSaveDef(virNWFilterDriverStatePtr driver,
return -1;
}
- if (virFileBuildPath(driver->configDir, def->name, ".xml",
- path, sizeof(path)) < 0) {
- virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("cannot construct config file path"));
- return -1;
- }
- if (!(nwfilter->configFile = strdup(path))) {
+ if (!(nwfilter->configFile = virFileBuildPath(driver->configDir,
+ def->name, ".xml"))) {
virReportOOMError();
return -1;
}
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 13a3622..5a069f5 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -1473,8 +1473,8 @@ virStoragePoolLoadAllConfigs(virStoragePoolObjListPtr pools,
}
while ((entry = readdir(dir))) {
- char path[PATH_MAX];
- char autostartLink[PATH_MAX];
+ char *path;
+ char *autostartLink;
virStoragePoolObjPtr pool;
if (entry->d_name[0] == '.')
@@ -1483,19 +1483,15 @@ virStoragePoolLoadAllConfigs(virStoragePoolObjListPtr pools,
if (!virFileHasSuffix(entry->d_name, ".xml"))
continue;
- if (virFileBuildPath(configDir, entry->d_name,
- NULL, path, PATH_MAX) < 0) {
- virStorageReportError(VIR_ERR_INTERNAL_ERROR,
- _("Config filename '%s/%s' is too long"),
- configDir, entry->d_name);
+ if (!(path = virFileBuildPath(configDir, entry->d_name, NULL))) {
+ virReportOOMError();
continue;
}
- if (virFileBuildPath(autostartDir, entry->d_name,
- NULL, autostartLink, PATH_MAX) < 0) {
- virStorageReportError(VIR_ERR_INTERNAL_ERROR,
- _("Autostart link path '%s/%s' is too long"),
- autostartDir, entry->d_name);
+ if (!(autostartLink = virFileBuildPath(autostartDir, entry->d_name,
+ NULL))) {
+ virReportOOMError();
+ VIR_FREE(path);
continue;
}
@@ -1503,6 +1499,9 @@ virStoragePoolLoadAllConfigs(virStoragePoolObjListPtr pools,
autostartLink);
if (pool)
virStoragePoolObjUnlock(pool);
+
+ VIR_FREE(path);
+ VIR_FREE(autostartLink);
}
closedir(dir);
@@ -1520,7 +1519,6 @@ virStoragePoolObjSaveDef(virStorageDriverStatePtr driver,
if (!pool->configFile) {
int err;
- char path[PATH_MAX];
if ((err = virFileMakePath(driver->configDir))) {
virReportSystemError(err,
@@ -1529,26 +1527,14 @@ virStoragePoolObjSaveDef(virStorageDriverStatePtr driver,
return -1;
}
- if (virFileBuildPath(driver->configDir, def->name, ".xml",
- path, sizeof(path)) < 0) {
- virStorageReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("cannot construct config file path"));
- return -1;
- }
- if (!(pool->configFile = strdup(path))) {
+ if (!(pool->configFile = virFileBuildPath(driver->configDir,
+ def->name, ".xml"))) {
virReportOOMError();
return -1;
}
- if (virFileBuildPath(driver->autostartDir, def->name, ".xml",
- path, sizeof(path)) < 0) {
- virStorageReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("cannot construct "
- "autostart link path"));
- VIR_FREE(pool->configFile);
- return -1;
- }
- if (!(pool->autostartLink = strdup(path))) {
+ if (!(pool->autostartLink = virFileBuildPath(driver->autostartDir,
+ def->name, ".xml"))) {
virReportOOMError();
VIR_FREE(pool->configFile);
return -1;
diff --git a/src/util/util.c b/src/util/util.c
index 43794b1..31feecc 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -1841,23 +1841,24 @@ cleanup:
return err;
}
-/* Build up a fully qualfiied path for a config file to be
+/* Build up a fully qualified path for a config file to be
* associated with a persistent guest or network */
-int virFileBuildPath(const char *dir,
- const char *name,
- const char *ext,
- char *buf,
- unsigned int buflen)
+char *
+virFileBuildPath(const char *dir, const char *name, const char *ext)
{
- if ((strlen(dir) + 1 + strlen(name) + (ext ? strlen(ext) : 0) + 1) >= (buflen-1))
- return -1;
+ char *path;
- strcpy(buf, dir);
- strcat(buf, "/");
- strcat(buf, name);
- if (ext)
- strcat(buf, ext);
- return 0;
+ if (ext == NULL) {
+ if (virAsprintf(&path, "%s/%s", dir, name) < 0) {
+ return NULL;
+ }
+ } else {
+ if (virAsprintf(&path, "%s/%s%s", dir, name, ext) < 0) {
+ return NULL;
+ }
+ }
+
+ return path;
}
diff --git a/src/util/util.h b/src/util/util.h
index 7b7722a..d320c40 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -146,11 +146,9 @@ int virDirCreate(const char *path, mode_t mode, uid_t uid, gid_t gid,
unsigned int flags) ATTRIBUTE_RETURN_CHECK;
int virFileMakePath(const char *path) ATTRIBUTE_RETURN_CHECK;
-int virFileBuildPath(const char *dir,
- const char *name,
- const char *ext,
- char *buf,
- unsigned int buflen) ATTRIBUTE_RETURN_CHECK;
+char *virFileBuildPath(const char *dir,
+ const char *name,
+ const char *ext) ATTRIBUTE_RETURN_CHECK;
int virFileAbsPath(const char *path,
char **abspath) ATTRIBUTE_RETURN_CHECK;
diff --git a/src/xen/xen_inotify.c b/src/xen/xen_inotify.c
index 7d4ba4c..5a997e6 100644
--- a/src/xen/xen_inotify.c
+++ b/src/xen/xen_inotify.c
@@ -387,7 +387,7 @@ xenInotifyOpen(virConnectPtr conn,
{
DIR *dh;
struct dirent *ent;
- char path[PATH_MAX];
+ char *path;
xenUnifiedPrivatePtr priv = (xenUnifiedPrivatePtr) conn->privateData;
if (priv->configDir) {
@@ -414,19 +414,21 @@ xenInotifyOpen(virConnectPtr conn,
continue;
/* Build the full file path */
- if ((strlen(priv->configDir) + 1 +
- strlen(ent->d_name) + 1) > PATH_MAX)
- continue;
- strcpy(path, priv->configDir);
- strcat(path, "/");
- strcat(path, ent->d_name);
+ if (!(path = virFileBuildPath(priv->configDir, ent->d_name, NULL))) {
+ virReportOOMError();
+ closedir(dh);
+ return -1;
+ }
if (xenInotifyAddDomainConfigInfo(conn, path) < 0 ) {
virXenInotifyError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Error adding file to config list"));
closedir(dh);
+ VIR_FREE(path);
return -1;
}
+
+ VIR_FREE(path);
}
closedir(dh);
}
diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index 7f73588..9225808 100644
--- a/src/xen/xm_internal.c
+++ b/src/xen/xm_internal.c
@@ -358,7 +358,7 @@ int xenXMConfigCacheRefresh (virConnectPtr conn) {
while ((ent = readdir(dh))) {
struct stat st;
- char path[PATH_MAX];
+ char *path;
/*
* Skip a bunch of crufty files that clearly aren't config files
@@ -387,15 +387,16 @@ int xenXMConfigCacheRefresh (virConnectPtr conn) {
continue;
/* Build the full file path */
- if ((strlen(priv->configDir) + 1 + strlen(ent->d_name) + 1) > PATH_MAX)
- continue;
- strcpy(path, priv->configDir);
- strcat(path, "/");
- strcat(path, ent->d_name);
+ if (!(path = virFileBuildPath(priv->configDir, ent->d_name, NULL))) {
+ virReportOOMError();
+ closedir(dh);
+ return -1;
+ }
/* Skip anything which isn't a file (takes care of scripts/ subdir */
if ((stat(path, &st) < 0) ||
(!S_ISREG(st.st_mode))) {
+ VIR_FREE(path);
continue;
}
@@ -404,6 +405,8 @@ int xenXMConfigCacheRefresh (virConnectPtr conn) {
if (xenXMConfigCacheAddFile(conn, path) < 0) {
/* Ignoring errors, since alot of stuff goes wrong in /etc/xen */
}
+
+ VIR_FREE(path);
}
/* Reap all entries which were not changed, by comparing
@@ -1046,10 +1049,11 @@ int xenXMDomainCreate(virDomainPtr domain) {
* Create a config file for a domain, based on an XML
* document describing its config
*/
-virDomainPtr xenXMDomainDefineXML(virConnectPtr conn, const char *xml) {
+virDomainPtr xenXMDomainDefineXML(virConnectPtr conn, const char *xml)
+{
virDomainPtr ret;
- char filename[PATH_MAX];
- const char * oldfilename;
+ char *filename;
+ const char *oldfilename;
virDomainDefPtr def = NULL;
xenXMConfCachePtr entry = NULL;
xenUnifiedPrivatePtr priv = (xenUnifiedPrivatePtr) conn->privateData;
@@ -1130,16 +1134,11 @@ virDomainPtr xenXMDomainDefineXML(virConnectPtr conn, const char *xml) {
entry = NULL;
}
- if ((strlen(priv->configDir) + 1 + strlen(def->name) + 1) > PATH_MAX) {
- xenXMError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("config file name is too long"));
+ if (!(filename = virFileBuildPath(priv->configDir, def->name, NULL))) {
+ virReportOOMError();
goto error;
}
- strcpy(filename, priv->configDir);
- strcat(filename, "/");
- strcat(filename, def->name);
-
if (xenXMConfigSaveFile(conn, filename, def) < 0)
goto error;
@@ -1172,9 +1171,11 @@ virDomainPtr xenXMDomainDefineXML(virConnectPtr conn, const char *xml) {
ret = virGetDomain(conn, def->name, def->uuid);
xenUnifiedUnlock(priv);
+ VIR_FREE(filename);
return (ret);
error:
+ VIR_FREE(filename);
VIR_FREE(entry);
virDomainDefFree(def);
xenUnifiedUnlock(priv);
--
1.7.0.4
From matthias.bolte at googlemail.com Sun Apr 3 09:21:15 2011
From: matthias.bolte at googlemail.com (Matthias Bolte)
Date: Sun, 3 Apr 2011 11:21:15 +0200
Subject: [libvirt] [PATCH 02/20] pci: Remove PATH_MAX sized stack allocations
In-Reply-To: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <1301822493-23013-3-git-send-email-matthias.bolte@googlemail.com>
Use virAsprintf instead of snprintf.
---
src/util/pci.c | 172 +++++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 127 insertions(+), 45 deletions(-)
diff --git a/src/util/pci.c b/src/util/pci.c
index 8d2dbb0..6ed96f4 100644
--- a/src/util/pci.c
+++ b/src/util/pci.c
@@ -775,38 +775,72 @@ pciResetDevice(pciDevice *dev,
}
-static void
-pciDriverDir(char *buf, size_t buflen, const char *driver)
+static int
+pciDriverDir(char **buffer, const char *driver)
{
- snprintf(buf, buflen, PCI_SYSFS "drivers/%s", driver);
+ VIR_FREE(*buffer);
+
+ if (virAsprintf(buffer, PCI_SYSFS "drivers/%s", driver) < 0) {
+ virReportOOMError();
+ return -1;
+ }
+
+ return 0;
}
-static void
-pciDriverFile(char *buf, size_t buflen, const char *driver, const char *file)
+static int
+pciDriverFile(char **buffer, const char *driver, const char *file)
{
- snprintf(buf, buflen, PCI_SYSFS "drivers/%s/%s", driver, file);
+ VIR_FREE(*buffer);
+
+ if (virAsprintf(buffer, PCI_SYSFS "drivers/%s/%s", driver, file) < 0) {
+ virReportOOMError();
+ return -1;
+ }
+
+ return 0;
}
-static void
-pciDeviceFile(char *buf, size_t buflen, const char *device, const char *file)
+static int
+pciDeviceFile(char **buffer, const char *device, const char *file)
{
- snprintf(buf, buflen, PCI_SYSFS "devices/%s/%s", device, file);
+ VIR_FREE(*buffer);
+
+ if (virAsprintf(buffer, PCI_SYSFS "devices/%s/%s", device, file) < 0) {
+ virReportOOMError();
+ return -1;
+ }
+
+ return 0;
}
static const char *
pciFindStubDriver(void)
{
- char drvpath[PATH_MAX];
+ char *drvpath = NULL;
int probed = 0;
recheck:
- pciDriverDir(drvpath, sizeof(drvpath), "pci-stub");
- if (virFileExists(drvpath))
+ if (pciDriverDir(&drvpath, "pci-stub") < 0) {
+ return NULL;
+ }
+
+ if (virFileExists(drvpath)) {
+ VIR_FREE(drvpath);
return "pci-stub";
- pciDriverDir(drvpath, sizeof(drvpath), "pciback");
- if (virFileExists(drvpath))
+ }
+
+ if (pciDriverDir(&drvpath, "pciback") < 0) {
+ return NULL;
+ }
+
+ if (virFileExists(drvpath)) {
+ VIR_FREE(drvpath);
return "pciback";
+ }
+
+ VIR_FREE(drvpath);
if (!probed) {
const char *const stubprobe[] = { MODPROBE, "pci-stub", NULL };
@@ -837,8 +871,9 @@ recheck:
static int
pciBindDeviceToStub(pciDevice *dev, const char *driver)
{
- char drvdir[PATH_MAX];
- char path[PATH_MAX];
+ int result = -1;
+ char *drvdir = NULL;
+ char *path = NULL;
/* Add the PCI device ID to the stub's dynamic ID table;
* this is needed to allow us to bind the device to the stub.
@@ -848,12 +883,15 @@ pciBindDeviceToStub(pciDevice *dev, const char *driver)
* is triggered for such a device, it will also be immediately
* bound by the stub.
*/
- pciDriverFile(path, sizeof(path), driver, "new_id");
+ if (pciDriverFile(&path, driver, "new_id") < 0) {
+ return -1;
+ }
+
if (virFileWriteStr(path, dev->id, 0) < 0) {
virReportSystemError(errno,
_("Failed to add PCI device ID '%s' to %s"),
dev->id, driver);
- return -1;
+ goto cleanup;
}
/* If the device is already bound to a driver, unbind it.
@@ -861,48 +899,69 @@ pciBindDeviceToStub(pciDevice *dev, const char *driver)
* PCI device happens to be IDE controller for the disk hosting
* your root filesystem.
*/
- pciDeviceFile(path, sizeof(path), dev->name, "driver/unbind");
+ if (pciDeviceFile(&path, dev->name, "driver/unbind") < 0) {
+ goto cleanup;
+ }
+
if (virFileExists(path) && virFileWriteStr(path, dev->name, 0) < 0) {
virReportSystemError(errno,
_("Failed to unbind PCI device '%s'"), dev->name);
- return -1;
+ goto cleanup;
}
/* If the device isn't already bound to pci-stub, try binding it now.
*/
- pciDriverDir(drvdir, sizeof(drvdir), driver);
- pciDeviceFile(path, sizeof(path), dev->name, "driver");
+ if (pciDriverDir(&drvdir, driver) < 0 ||
+ pciDeviceFile(&path, dev->name, "driver") < 0) {
+ goto cleanup;
+ }
+
if (!virFileLinkPointsTo(path, drvdir)) {
/* Xen's pciback.ko wants you to use new_slot first */
- pciDriverFile(path, sizeof(path), driver, "new_slot");
+ if (pciDriverFile(&path, driver, "new_slot") < 0) {
+ goto cleanup;
+ }
+
if (virFileExists(path) && virFileWriteStr(path, dev->name, 0) < 0) {
virReportSystemError(errno,
_("Failed to add slot for PCI device '%s' to %s"),
dev->name, driver);
- return -1;
+ goto cleanup;
+ }
+
+ if (pciDriverFile(&path, driver, "bind") < 0) {
+ goto cleanup;
}
- pciDriverFile(path, sizeof(path), driver, "bind");
if (virFileWriteStr(path, dev->name, 0) < 0) {
virReportSystemError(errno,
_("Failed to bind PCI device '%s' to %s"),
dev->name, driver);
- return -1;
+ goto cleanup;
}
}
/* If 'remove_id' exists, remove the device id from pci-stub's dynamic
* ID table so that 'drivers_probe' works below.
*/
- pciDriverFile(path, sizeof(path), driver, "remove_id");
+ if (pciDriverFile(&path, driver, "remove_id") < 0) {
+ goto cleanup;
+ }
+
if (virFileExists(path) && virFileWriteStr(path, dev->id, 0) < 0) {
virReportSystemError(errno,
_("Failed to remove PCI ID '%s' from %s"),
dev->id, driver);
- return -1;
+ goto cleanup;
}
- return 0;
+ result = 0;
+
+cleanup:
+ VIR_FREE(drvdir);
+ VIR_FREE(path);
+
+ return result;
}
int
@@ -927,49 +986,67 @@ pciDettachDevice(pciDevice *dev, pciDeviceList *activeDevs)
static int
pciUnBindDeviceFromStub(pciDevice *dev, const char *driver)
{
- char drvdir[PATH_MAX];
- char path[PATH_MAX];
+ int result = -1;
+ char *drvdir = NULL;
+ char *path = NULL;
/* If the device is bound to stub, unbind it.
*/
- pciDriverDir(drvdir, sizeof(drvdir), driver);
- pciDeviceFile(path, sizeof(path), dev->name, "driver");
+ if (pciDriverDir(&drvdir, driver) < 0 ||
+ pciDeviceFile(&path, dev->name, "driver") < 0) {
+ goto cleanup;
+ }
+
if (virFileExists(drvdir) && virFileLinkPointsTo(path, drvdir)) {
- pciDriverFile(path, sizeof(path), driver, "unbind");
+ if (pciDriverFile(&path, driver, "unbind") < 0) {
+ goto cleanup;
+ }
+
if (virFileWriteStr(path, dev->name, 0) < 0) {
virReportSystemError(errno,
_("Failed to bind PCI device '%s' to %s"),
dev->name, driver);
- return -1;
+ goto cleanup;
}
}
/* Xen's pciback.ko wants you to use remove_slot on the specific device */
- pciDriverFile(path, sizeof(path), driver, "remove_slot");
+ if (pciDriverFile(&path, driver, "remove_slot") < 0) {
+ goto cleanup;
+ }
+
if (virFileExists(path) && virFileWriteStr(path, dev->name, 0) < 0) {
virReportSystemError(errno,
_("Failed to remove slot for PCI device '%s' to %s"),
dev->name, driver);
- return -1;
+ goto cleanup;
}
-
/* Trigger a re-probe of the device is not in the stub's dynamic
* ID table. If the stub is available, but 'remove_id' isn't
* available, then re-probing would just cause the device to be
* re-bound to the stub.
*/
- pciDriverFile(path, sizeof(path), driver, "remove_id");
+ if (pciDriverFile(&path, driver, "remove_id") < 0) {
+ goto cleanup;
+ }
+
if (!virFileExists(drvdir) || virFileExists(path)) {
if (virFileWriteStr(PCI_SYSFS "drivers_probe", dev->name, 0) < 0) {
virReportSystemError(errno,
_("Failed to trigger a re-probe for PCI device '%s'"),
dev->name);
- return -1;
+ goto cleanup;
}
}
- return 0;
+ result = 0;
+
+cleanup:
+ VIR_FREE(drvdir);
+ VIR_FREE(path);
+
+ return result;
}
int
@@ -1103,15 +1180,20 @@ pciWaitForDeviceCleanup(pciDevice *dev, const char *matcher)
static char *
pciReadDeviceID(pciDevice *dev, const char *id_name)
{
- char path[PATH_MAX];
+ char *path;
char *id_str;
- snprintf(path, sizeof(path), PCI_SYSFS "devices/%s/%s",
- dev->name, id_name);
+ if (pciDeviceFile(&path, dev->name, id_name) < 0) {
+ return NULL;
+ }
/* ID string is '0xNNNN\n' ... i.e. 7 bytes */
- if (virFileReadAll(path, 7, &id_str) < 0)
+ if (virFileReadAll(path, 7, &id_str) < 0) {
+ VIR_FREE(path);
return NULL;
+ }
+
+ VIR_FREE(path);
/* Check for 0x suffix */
if (id_str[0] != '0' || id_str[1] != 'x') {
--
1.7.0.4
From matthias.bolte at googlemail.com Sun Apr 3 09:21:16 2011
From: matthias.bolte at googlemail.com (Matthias Bolte)
Date: Sun, 3 Apr 2011 11:21:16 +0200
Subject: [libvirt] [PATCH 03/20] ebtables: Remove PATH_MAX sized stack
allocation
In-Reply-To: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <1301822493-23013-4-git-send-email-matthias.bolte@googlemail.com>
---
src/util/ebtables.c | 44 +++++++++++++++++++++++++++++---------------
1 files changed, 29 insertions(+), 15 deletions(-)
diff --git a/src/util/ebtables.c b/src/util/ebtables.c
index e3b8da4..27dce5d 100644
--- a/src/util/ebtables.c
+++ b/src/util/ebtables.c
@@ -266,29 +266,43 @@ ebtablesAddRemoveRule(ebtRules *rules, int action, const char *arg, ...)
ebtablesContext *
ebtablesContextNew(const char *driver)
{
- ebtablesContext *ctx;
- char chain[PATH_MAX];
+ bool success = false;
+ ebtablesContext *ctx = NULL;
+ char *input_chain = NULL;
+ char *forward_chain = NULL;
+ char *nat_chain = NULL;
if (VIR_ALLOC(ctx) < 0)
return NULL;
- snprintf(chain, sizeof(chain), "libvirt_%s_INPUT", driver);
- if (!(ctx->input_filter = ebtRulesNew("filter", chain)))
- goto error;
+ if (virAsprintf(&input_chain, "libvirt_%s_INPUT", driver) < 0 ||
+ virAsprintf(&forward_chain, "libvirt_%s_FORWARD", driver) < 0 ||
+ virAsprintf(&nat_chain, "libvirt_%s_POSTROUTING", driver) < 0) {
+ goto cleanup;
+ }
- snprintf(chain, sizeof(chain), "libvirt_%s_FORWARD", driver);
- if (!(ctx->forward_filter = ebtRulesNew("filter", chain)))
- goto error;
+ if (!(ctx->input_filter = ebtRulesNew("filter", input_chain)))
+ goto cleanup;
- snprintf(chain, sizeof(chain), "libvirt_%s_POSTROUTING", driver);
- if (!(ctx->nat_postrouting = ebtRulesNew("nat", chain)))
- goto error;
+ if (!(ctx->forward_filter = ebtRulesNew("filter", forward_chain)))
+ goto cleanup;
- return ctx;
+ if (!(ctx->nat_postrouting = ebtRulesNew("nat", nat_chain)))
+ goto cleanup;
- error:
- ebtablesContextFree(ctx);
- return NULL;
+ success = true;
+
+cleanup:
+ VIR_FREE(input_chain);
+ VIR_FREE(forward_chain);
+ VIR_FREE(nat_chain);
+
+ if (!success) {
+ ebtablesContextFree(ctx);
+ ctx = NULL;
+ }
+
+ return ctx;
}
/**
--
1.7.0.4
From matthias.bolte at googlemail.com Sun Apr 3 09:21:13 2011
From: matthias.bolte at googlemail.com (Matthias Bolte)
Date: Sun, 3 Apr 2011 11:21:13 +0200
Subject: [libvirt] [PATCH 00/20] Remove large stack allocations
Message-ID: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
This is meant for post-0.9.0.
The series removes many large stack allocations from the code base and makes
it compile with -Wframe-larger-than=2500. This was inspired by Dan's patch for
using gnulib's manywarnings & warnings modules [1]. Where he mentioned that
currently -Wframe-larger-than=20480 is required.
This series doesn't address stack usage in the test suite.
[1] https://www.redhat.com/archives/libvir-list/2011-April/msg00060.html
Matthias
From matthias.bolte at googlemail.com Sun Apr 3 09:21:17 2011
From: matthias.bolte at googlemail.com (Matthias Bolte)
Date: Sun, 3 Apr 2011 11:21:17 +0200
Subject: [libvirt] [PATCH 04/20] virt-aa-helper: Remove PATH_MAX sized stack
allocations
In-Reply-To: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <1301822493-23013-5-git-send-email-matthias.bolte@googlemail.com>
---
src/security/virt-aa-helper.c | 46 +++++++++++++++++++++++++----------------
1 files changed, 28 insertions(+), 18 deletions(-)
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index 77df514..bb716e6 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -188,8 +188,9 @@ replace_string(char *orig, const size_t len, const char *oldstr,
static int
parserCommand(const char *profile_name, const char cmd)
{
+ int result = -1;
char flag[3];
- char profile[PATH_MAX];
+ char *profile;
int status;
int ret;
@@ -200,15 +201,15 @@ parserCommand(const char *profile_name, const char cmd)
snprintf(flag, 3, "-%c", cmd);
- if (snprintf(profile, PATH_MAX, "%s/%s",
- APPARMOR_DIR "/libvirt", profile_name) > PATH_MAX - 1) {
+ if (virAsprintf(&profile, "%s/%s",
+ APPARMOR_DIR "/libvirt", profile_name) < 0) {
vah_error(NULL, 0, _("profile name exceeds maximum length"));
return -1;
}
if (!virFileExists(profile)) {
vah_error(NULL, 0, _("profile does not exist"));
- return -1;
+ goto cleanup;
} else {
const char * const argv[] = {
"/sbin/apparmor_parser", flag, profile, NULL
@@ -217,18 +218,23 @@ parserCommand(const char *profile_name, const char cmd)
(WIFEXITED(status) && WEXITSTATUS(status) != 0)) {
if (ret != 0) {
vah_error(NULL, 0, _("failed to run apparmor_parser"));
- return -1;
+ goto cleanup;
} else if (cmd == 'R' && WIFEXITED(status) &&
WEXITSTATUS(status) == 234) {
vah_warning(_("unable to unload already unloaded profile"));
} else {
vah_error(NULL, 0, _("apparmor_parser exited with error"));
- return -1;
+ goto cleanup;
}
}
}
- return 0;
+ result = 0;
+
+cleanup:
+ VIR_FREE(profile);
+
+ return result;
}
/*
@@ -308,7 +314,7 @@ static int
create_profile(const char *profile, const char *profile_name,
const char *profile_files)
{
- char template[PATH_MAX];
+ char *template;
char *tcontent = NULL;
char *pcontent = NULL;
char *replace_name = NULL;
@@ -324,8 +330,7 @@ create_profile(const char *profile, const char *profile_name,
goto end;
}
- if (snprintf(template, PATH_MAX, "%s/TEMPLATE",
- APPARMOR_DIR "/libvirt") > PATH_MAX - 1) {
+ if (virAsprintf(&template, "%s/TEMPLATE", APPARMOR_DIR "/libvirt") < 0) {
vah_error(NULL, 0, _("template name exceeds maximum length"));
goto end;
}
@@ -409,6 +414,7 @@ create_profile(const char *profile, const char *profile_name,
clean_tcontent:
VIR_FREE(tcontent);
end:
+ VIR_FREE(template);
return rc;
}
@@ -1134,8 +1140,8 @@ main(int argc, char **argv)
vahControl _ctl, *ctl = &_ctl;
virBuffer buf = VIR_BUFFER_INITIALIZER;
int rc = -1;
- char profile[PATH_MAX];
- char include_file[PATH_MAX];
+ char *profile = NULL;
+ char *include_file = NULL;
if (setlocale(LC_ALL, "") == NULL ||
bindtextdomain(PACKAGE, LOCALEDIR) == NULL ||
@@ -1164,13 +1170,13 @@ main(int argc, char **argv)
if (vahParseArgv(ctl, argc, argv) != 0)
vah_error(ctl, 1, _("could not parse arguments"));
- if (snprintf(profile, PATH_MAX, "%s/%s",
- APPARMOR_DIR "/libvirt", ctl->uuid) > PATH_MAX - 1)
- vah_error(ctl, 1, _("profile name exceeds maximum length"));
+ if (virAsprintf(&profile, "%s/%s",
+ APPARMOR_DIR "/libvirt", ctl->uuid) < 0)
+ vah_error(ctl, 0, _("could not allocate memory"));
- if (snprintf(include_file, PATH_MAX, "%s/%s.files",
- APPARMOR_DIR "/libvirt", ctl->uuid) > PATH_MAX - 1)
- vah_error(ctl, 1, _("disk profile name exceeds maximum length"));
+ if (virAsprintf(&include_file, "%s/%s.files",
+ APPARMOR_DIR "/libvirt", ctl->uuid) < 0)
+ vah_error(ctl, 0, _("could not allocate memory"));
if (ctl->cmd == 'a')
rc = parserLoad(ctl->uuid);
@@ -1258,5 +1264,9 @@ main(int argc, char **argv)
}
vahDeinit(ctl);
+
+ VIR_FREE(profile);
+ VIR_FREE(include_file);
+
exit(rc == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
}
--
1.7.0.4
From matthias.bolte at googlemail.com Sun Apr 3 09:21:18 2011
From: matthias.bolte at googlemail.com (Matthias Bolte)
Date: Sun, 3 Apr 2011 11:21:18 +0200
Subject: [libvirt] [PATCH 05/20] phyp: Remove 16kb stack allocation
In-Reply-To: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <1301822493-23013-6-git-send-email-matthias.bolte@googlemail.com>
Allocate on the heap instead.
---
src/phyp/phyp_driver.c | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 51f9ff6..fe2e99d 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -115,12 +115,18 @@ phypExec(LIBSSH2_SESSION * session, char *cmd, int *exit_status,
LIBSSH2_CHANNEL *channel;
ConnectionData *connection_data = conn->networkPrivateData;
virBuffer tex_ret = VIR_BUFFER_INITIALIZER;
- char buffer[0x4000] = { 0 };
+ char *buffer = NULL;
+ size_t buffer_size = 16384;
int exitcode;
int bytecount = 0;
int sock = connection_data->sock;
int rc = 0;
+ if (VIR_ALLOC_N(buffer, buffer_size) < 0) {
+ virReportOOMError();
+ return NULL;
+ }
+
/* Exec non-blocking on the remove host */
while ((channel = libssh2_channel_open_session(session)) == NULL &&
libssh2_session_last_error(session, NULL, NULL, 0) ==
@@ -144,7 +150,7 @@ phypExec(LIBSSH2_SESSION * session, char *cmd, int *exit_status,
for (;;) {
/* loop until we block */
do {
- rc = libssh2_channel_read(channel, buffer, sizeof(buffer));
+ rc = libssh2_channel_read(channel, buffer, buffer_size);
if (rc > 0) {
bytecount += rc;
virBufferVSprintf(&tex_ret, "%s", buffer);
@@ -179,9 +185,12 @@ phypExec(LIBSSH2_SESSION * session, char *cmd, int *exit_status,
err:
(*exit_status) = SSH_CMD_ERR;
virBufferFreeAndReset(&tex_ret);
+ VIR_FREE(buffer);
return NULL;
exit:
+ VIR_FREE(buffer);
+
if (virBufferError(&tex_ret)) {
virBufferFreeAndReset(&tex_ret);
virReportOOMError();
--
1.7.0.4
From matthias.bolte at googlemail.com Sun Apr 3 09:21:19 2011
From: matthias.bolte at googlemail.com (Matthias Bolte)
Date: Sun, 3 Apr 2011 11:21:19 +0200
Subject: [libvirt] [PATCH 06/20] qemu: Use heap allocated memory to read the
monitor greeting
In-Reply-To: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <1301822493-23013-7-git-send-email-matthias.bolte@googlemail.com>
Removing a 4kb stack allocation.
Reduce stack buffer for virStrerror to the common 1kb instead of 4kb.
---
src/qemu/qemu_process.c | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 90fcea0..fc9fdae 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1012,7 +1012,8 @@ static int
qemuProcessWaitForMonitor(struct qemud_driver* driver,
virDomainObjPtr vm, off_t pos)
{
- char buf[4096] = ""; /* Plenty of space to get startup greeting */
+ char *buf;
+ size_t buf_size = 4096; /* Plenty of space to get startup greeting */
int logfd;
int ret = -1;
virHashTablePtr paths = NULL;
@@ -1020,7 +1021,12 @@ qemuProcessWaitForMonitor(struct qemud_driver* driver,
if ((logfd = qemuProcessLogReadFD(driver->logDir, vm->def->name, pos)) < 0)
return -1;
- if (qemuProcessReadLogOutput(vm, logfd, buf, sizeof(buf),
+ if (VIR_ALLOC_N(buf, buf_size) < 0) {
+ virReportOOMError();
+ return -1;
+ }
+
+ if (qemuProcessReadLogOutput(vm, logfd, buf, buf_size,
qemuProcessFindCharDevicePTYs,
"console", 30) < 0)
goto closelog;
@@ -1053,16 +1059,18 @@ cleanup:
if (kill(vm->pid, 0) == -1 && errno == ESRCH) {
/* VM is dead, any other error raised in the interim is probably
* not as important as the qemu cmdline output */
- qemuProcessReadLogFD(logfd, buf, sizeof(buf), strlen(buf));
+ qemuProcessReadLogFD(logfd, buf, buf_size, strlen(buf));
qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("process exited while connecting to monitor: %s"),
buf);
ret = -1;
}
+ VIR_FREE(buf);
+
closelog:
if (VIR_CLOSE(logfd) < 0) {
- char ebuf[4096];
+ char ebuf[1024];
VIR_WARN("Unable to close logfile: %s",
virStrerror(errno, ebuf, sizeof ebuf));
}
--
1.7.0.4
From matthias.bolte at googlemail.com Sun Apr 3 09:21:20 2011
From: matthias.bolte at googlemail.com (Matthias Bolte)
Date: Sun, 3 Apr 2011 11:21:20 +0200
Subject: [libvirt] [PATCH 07/20] sasl: Remove stack allocated 8kb temporary
buffers
In-Reply-To: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <1301822493-23013-8-git-send-email-matthias.bolte@googlemail.com>
Move the buffers to the heap allocated client/private data structs.
---
daemon/libvirtd.c | 10 ++++++----
daemon/libvirtd.h | 1 +
src/remote/remote_driver.c | 8 +++++---
3 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 024f56f..42cbe5d 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -1766,15 +1766,17 @@ static ssize_t qemudClientReadSASL(struct qemud_client *client) {
/* Need to read some more data off the wire */
if (client->saslDecoded == NULL) {
int ret;
- char encoded[8192];
- ssize_t encodedLen = sizeof(encoded);
- encodedLen = qemudClientReadBuf(client, encoded, encodedLen);
+ ssize_t encodedLen;
+
+ encodedLen = qemudClientReadBuf(client, client->saslTemporary,
+ sizeof(client->saslTemporary));
if (encodedLen <= 0)
return encodedLen;
- ret = sasl_decode(client->saslconn, encoded, encodedLen,
+ ret = sasl_decode(client->saslconn, client->saslTemporary, encodedLen,
&client->saslDecoded, &client->saslDecodedLength);
+
if (ret != SASL_OK) {
VIR_ERROR(_("failed to decode SASL data %s"),
sasl_errstring(ret, NULL, NULL));
diff --git a/daemon/libvirtd.h b/daemon/libvirtd.h
index 7da3cfd..d37c3fd 100644
--- a/daemon/libvirtd.h
+++ b/daemon/libvirtd.h
@@ -213,6 +213,7 @@ struct qemud_client {
unsigned int saslEncodedLength;
unsigned int saslEncodedOffset;
char *saslUsername;
+ char saslTemporary[8192]; /* temorary holds data to be decoded */
# endif
/* Count of meages in 'dx' or 'tx' queue
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index bf94e70..942ff4b 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -174,6 +174,8 @@ struct private_data {
const char *saslEncoded;
unsigned int saslEncodedLength;
unsigned int saslEncodedOffset;
+
+ char saslTemporary[8192]; /* temorary holds data to be decoded */
#endif
/* Buffer for incoming data packets
@@ -10063,15 +10065,15 @@ remoteIOReadMessage(struct private_data *priv) {
#if HAVE_SASL
if (priv->saslconn) {
if (priv->saslDecoded == NULL) {
- char encoded[8192];
int ret, err;
- ret = remoteIOReadBuffer(priv, encoded, sizeof(encoded));
+ ret = remoteIOReadBuffer(priv, priv->saslTemporary,
+ sizeof(priv->saslTemporary));
if (ret < 0)
return -1;
if (ret == 0)
return 0;
- err = sasl_decode(priv->saslconn, encoded, ret,
+ err = sasl_decode(priv->saslconn, priv->saslTemporary, ret,
&priv->saslDecoded, &priv->saslDecodedLength);
if (err != SASL_OK) {
remoteError(VIR_ERR_INTERNAL_ERROR,
--
1.7.0.4
From matthias.bolte at googlemail.com Sun Apr 3 09:21:21 2011
From: matthias.bolte at googlemail.com (Matthias Bolte)
Date: Sun, 3 Apr 2011 11:21:21 +0200
Subject: [libvirt] [PATCH 08/20] xenxs: Remove PATH_MAX sized stack
alocation in XM script parsing
In-Reply-To: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <1301822493-23013-9-git-send-email-matthias.bolte@googlemail.com>
---
src/xenxs/xen_xm.c | 14 ++++++--------
1 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 0acd120..22ad788 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -211,6 +211,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
const char *defaultArch, *defaultMachine;
int vmlocaltime = 0;
unsigned long count;
+ char *script = NULL;
if (VIR_ALLOC(def) < 0) {
virReportOOMError();
@@ -556,7 +557,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
if (list && list->type == VIR_CONF_LIST) {
list = list->list;
while (list) {
- char script[PATH_MAX];
char model[10];
char type[10];
char ip[16];
@@ -567,7 +567,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
bridge[0] = '\0';
mac[0] = '\0';
- script[0] = '\0';
ip[0] = '\0';
model[0] = '\0';
type[0] = '\0';
@@ -602,12 +601,10 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
goto skipnic;
}
} else if (STRPREFIX(key, "script=")) {
- int len = nextkey ? (nextkey - data) : sizeof(script) - 1;
- if (virStrncpy(script, data, len, sizeof(script)) == NULL) {
- XENXS_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("Script %s too big for destination"),
- data);
- goto skipnic;
+ int len = nextkey ? (nextkey - data) : strlen(data);
+ VIR_FREE(script);
+ if (!(script = strndup(data, len))) {
+ goto no_memory;
}
} else if (STRPREFIX(key, "model=")) {
int len = nextkey ? (nextkey - data) : sizeof(model) - 1;
@@ -1043,6 +1040,7 @@ cleanup:
virDomainNetDefFree(net);
virDomainDiskDefFree(disk);
virDomainDefFree(def);
+ VIR_FREE(script);
return NULL;
}
--
1.7.0.4
From matthias.bolte at googlemail.com Sun Apr 3 09:21:23 2011
From: matthias.bolte at googlemail.com (Matthias Bolte)
Date: Sun, 3 Apr 2011 11:21:23 +0200
Subject: [libvirt] [PATCH 10/20] virsh: Remove two 4kb stack allocations
In-Reply-To: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <1301822493-23013-11-git-send-email-matthias.bolte@googlemail.com>
---
tools/virsh.c | 23 +++++++++++++++++------
1 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 19e3449..99da054 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -2052,7 +2052,7 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
virDomainInfo info;
virDomainPtr dom;
virSecurityModel secmodel;
- virSecurityLabel seclabel;
+ virSecurityLabelPtr seclabel;
int persistent = 0;
int ret = TRUE, autostart;
unsigned int id;
@@ -2138,15 +2138,22 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, "%-15s %s\n", _("Security DOI:"), secmodel.doi);
/* Security labels are only valid for active domains */
- memset(&seclabel, 0, sizeof seclabel);
- if (virDomainGetSecurityLabel(dom, &seclabel) == -1) {
+ if (VIR_ALLOC(seclabel) < 0) {
virDomainFree(dom);
return FALSE;
+ }
+
+ if (virDomainGetSecurityLabel(dom, seclabel) == -1) {
+ virDomainFree(dom);
+ VIR_FREE(seclabel);
+ return FALSE;
} else {
- if (seclabel.label[0] != '\0')
+ if (seclabel->label[0] != '\0')
vshPrint(ctl, "%-15s %s (%s)\n", _("Security label:"),
- seclabel.label, seclabel.enforcing ? "enforcing" : "permissive");
+ seclabel->label, seclabel->enforcing ? "enforcing" : "permissive");
}
+
+ VIR_FREE(seclabel);
}
}
virDomainFree(dom);
@@ -12141,7 +12148,7 @@ vshOpenLogFile(vshControl *ctl)
static void
vshOutputLogFile(vshControl *ctl, int log_level, const char *msg_format, va_list ap)
{
- char msg_buf[MSG_BUFFER];
+ char *msg_buf;
const char *lvl = "";
struct timeval stTimeval;
struct tm *stTm;
@@ -12149,6 +12156,8 @@ vshOutputLogFile(vshControl *ctl, int log_level, const char *msg_format, va_list
if (ctl->log_fd == -1)
return;
+ msg_buf = vshMalloc(ctl, MSG_BUFFER);
+
/**
* create log format
*
@@ -12199,6 +12208,8 @@ vshOutputLogFile(vshControl *ctl, int log_level, const char *msg_format, va_list
vshCloseLogFile(ctl);
vshError(ctl, "%s", _("failed to write the log file"));
}
+
+ VIR_FREE(msg_buf);
}
/**
--
1.7.0.4
From matthias.bolte at googlemail.com Sun Apr 3 09:21:22 2011
From: matthias.bolte at googlemail.com (Matthias Bolte)
Date: Sun, 3 Apr 2011 11:21:22 +0200
Subject: [libvirt] [PATCH 09/20] Use virFileAbsPath instead of manually
creating the absolute path
In-Reply-To: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <1301822493-23013-10-git-send-email-matthias.bolte@googlemail.com>
Removes multiple 4kb stack allocations.
---
src/libvirt.c | 113 +++++++++++++++++++++------------------------------------
1 files changed, 42 insertions(+), 71 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index 8be18d4..25f8d41 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -2238,7 +2238,6 @@ error:
int
virDomainSave(virDomainPtr domain, const char *to)
{
- char filepath[4096];
virConnectPtr conn;
VIR_DOMAIN_DEBUG(domain, "to=%s", to);
@@ -2260,29 +2259,24 @@ virDomainSave(virDomainPtr domain, const char *to)
goto error;
}
- /*
- * We must absolutize the file path as the save is done out of process
- * TODO: check for URI when libxml2 is linked in.
- */
- if (to[0] != '/') {
- unsigned int len, t;
+ if (conn->driver->domainSave) {
+ int ret;
+ char *absolute_to;
- t = strlen(to);
- if (getcwd(filepath, sizeof(filepath) - (t + 3)) == NULL)
- return -1;
- len = strlen(filepath);
- /* that should be covered by getcwd() semantic, but be 100% sure */
- if (len > sizeof(filepath) - (t + 3))
- return -1;
- filepath[len] = '/';
- strcpy(&filepath[len + 1], to);
- to = &filepath[0];
+ /*
+ * We must absolutize the file path as the save is done out of process
+ * TODO: check for URI when libxml2 is linked in.
+ */
+ if (virFileAbsPath(to, &absolute_to) < 0) {
+ virLibConnError(VIR_ERR_INTERNAL_ERROR,
+ _("could not build absolute output file path"));
+ goto error;
+ }
- }
+ ret = conn->driver->domainSave(domain, absolute_to);
+
+ VIR_FREE(absolute_to);
- if (conn->driver->domainSave) {
- int ret;
- ret = conn->driver->domainSave (domain, to);
if (ret < 0)
goto error;
return ret;
@@ -2298,7 +2292,7 @@ error:
/**
* virDomainRestore:
* @conn: pointer to the hypervisor connection
- * @from: path to the
+ * @from: path to the input file
*
* This method will restore a domain saved to disk by virDomainSave().
*
@@ -2307,7 +2301,6 @@ error:
int
virDomainRestore(virConnectPtr conn, const char *from)
{
- char filepath[4096];
VIR_DEBUG("conn=%p, from=%s", conn, from);
virResetLastError();
@@ -2326,34 +2319,24 @@ virDomainRestore(virConnectPtr conn, const char *from)
goto error;
}
- /*
- * We must absolutize the file path as the restore is done out of process
- * TODO: check for URI when libxml2 is linked in.
- */
- if (from[0] != '/') {
- unsigned int len, t;
+ if (conn->driver->domainRestore) {
+ int ret;
+ char *absolute_from;
- t = strlen(from);
- if (getcwd(filepath, sizeof(filepath) - (t + 3)) == NULL) {
- virLibConnError(VIR_ERR_SYSTEM_ERROR,
- _("cannot get working directory"));
- goto error;
- }
- len = strlen(filepath);
- /* that should be covered by getcwd() semantic, but be 100% sure */
- if (len > sizeof(filepath) - (t + 3)) {
+ /*
+ * We must absolutize the file path as the restore is done out of process
+ * TODO: check for URI when libxml2 is linked in.
+ */
+ if (virFileAbsPath(from, &absolute_from) < 0) {
virLibConnError(VIR_ERR_INTERNAL_ERROR,
- _("path too long"));
+ _("could not build absolute input file path"));
goto error;
}
- filepath[len] = '/';
- strcpy(&filepath[len + 1], from);
- from = &filepath[0];
- }
- if (conn->driver->domainRestore) {
- int ret;
- ret = conn->driver->domainRestore (conn, from);
+ ret = conn->driver->domainRestore(conn, absolute_from);
+
+ VIR_FREE(absolute_from);
+
if (ret < 0)
goto error;
return ret;
@@ -2381,7 +2364,6 @@ error:
int
virDomainCoreDump(virDomainPtr domain, const char *to, int flags)
{
- char filepath[4096];
virConnectPtr conn;
VIR_DOMAIN_DEBUG(domain, "to=%s, flags=%d", to, flags);
@@ -2403,35 +2385,24 @@ virDomainCoreDump(virDomainPtr domain, const char *to, int flags)
goto error;
}
- /*
- * We must absolutize the file path as the save is done out of process
- * TODO: check for URI when libxml2 is linked in.
- */
- if (to[0] != '/') {
- unsigned int len, t;
+ if (conn->driver->domainCoreDump) {
+ int ret;
+ char *absolute_to;
- t = strlen(to);
- if (getcwd(filepath, sizeof(filepath) - (t + 3)) == NULL) {
- virLibDomainError(VIR_ERR_SYSTEM_ERROR,
- _("cannot get current directory"));
- goto error;
- }
- len = strlen(filepath);
- /* that should be covered by getcwd() semantic, but be 100% sure */
- if (len > sizeof(filepath) - (t + 3)) {
- virLibDomainError(VIR_ERR_INTERNAL_ERROR,
- _("path too long"));
+ /*
+ * We must absolutize the file path as the save is done out of process
+ * TODO: check for URI when libxml2 is linked in.
+ */
+ if (virFileAbsPath(to, &absolute_to) < 0) {
+ virLibConnError(VIR_ERR_INTERNAL_ERROR,
+ _("could not build absolute core file path"));
goto error;
}
- filepath[len] = '/';
- strcpy(&filepath[len + 1], to);
- to = &filepath[0];
- }
+ ret = conn->driver->domainCoreDump(domain, absolute_to, flags);
+
+ VIR_FREE(absolute_to);
- if (conn->driver->domainCoreDump) {
- int ret;
- ret = conn->driver->domainCoreDump (domain, to, flags);
if (ret < 0)
goto error;
return ret;
--
1.7.0.4
From matthias.bolte at googlemail.com Sun Apr 3 09:21:24 2011
From: matthias.bolte at googlemail.com (Matthias Bolte)
Date: Sun, 3 Apr 2011 11:21:24 +0200
Subject: [libvirt] [PATCH 11/20] phyp: Remove the last instance of stack
allocating a 4kb volume key
In-Reply-To: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <1301822493-23013-12-git-send-email-matthias.bolte@googlemail.com>
---
src/phyp/phyp_driver.c | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index fe2e99d..76207c2 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -2362,13 +2362,22 @@ phypBuildVolume(virConnectPtr conn, const char *lvname, const char *spname,
static virStorageVolPtr
phypVolumeLookupByName(virStoragePoolPtr pool, const char *volname)
{
+ char *key;
+ virStorageVolPtr vol;
- char key[MAX_KEY_SIZE];
+ if (VIR_ALLOC_N(key, MAX_KEY_SIZE) < 0) {
+ virReportOOMError();
+ return NULL;
+ }
if (phypVolumeGetKey(pool->conn, key, volname) == -1)
return NULL;
- return virGetStorageVol(pool->conn, pool->name, volname, key);
+ vol = virGetStorageVol(pool->conn, pool->name, volname, key);
+
+ VIR_FREE(key);
+
+ return vol;
}
static virStorageVolPtr
--
1.7.0.4
From matthias.bolte at googlemail.com Sun Apr 3 09:21:25 2011
From: matthias.bolte at googlemail.com (Matthias Bolte)
Date: Sun, 3 Apr 2011 11:21:25 +0200
Subject: [libvirt] [PATCH 12/20] daemon: Remove 4kb stack allocation of
security label
In-Reply-To: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <1301822493-23013-13-git-send-email-matthias.bolte@googlemail.com>
---
daemon/remote.c | 20 ++++++++++++++------
1 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index 1700c2d..dd85ef1 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -1607,7 +1607,7 @@ remoteDispatchDomainGetSecurityLabel(struct qemud_server *server ATTRIBUTE_UNUSE
remote_domain_get_security_label_ret *ret)
{
virDomainPtr dom;
- virSecurityLabel seclabel;
+ virSecurityLabelPtr seclabel;
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
@@ -1615,22 +1615,30 @@ remoteDispatchDomainGetSecurityLabel(struct qemud_server *server ATTRIBUTE_UNUSE
return -1;
}
- memset(&seclabel, 0, sizeof seclabel);
- if (virDomainGetSecurityLabel(dom, &seclabel) == -1) {
+ if (VIR_ALLOC(seclabel) < 0) {
+ virDomainFree(dom);
+ remoteDispatchOOMError(rerr);
+ return -1;
+ }
+
+ if (virDomainGetSecurityLabel(dom, seclabel) == -1) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
+ VIR_FREE(seclabel);
return -1;
}
- ret->label.label_len = strlen(seclabel.label) + 1;
+ ret->label.label_len = strlen(seclabel->label) + 1;
if (VIR_ALLOC_N(ret->label.label_val, ret->label.label_len) < 0) {
virDomainFree(dom);
+ VIR_FREE(seclabel);
remoteDispatchOOMError(rerr);
return -1;
}
- strcpy(ret->label.label_val, seclabel.label);
- ret->enforcing = seclabel.enforcing;
+ strcpy(ret->label.label_val, seclabel->label);
+ ret->enforcing = seclabel->enforcing;
virDomainFree(dom);
+ VIR_FREE(seclabel);
return 0;
}
--
1.7.0.4
From matthias.bolte at googlemail.com Sun Apr 3 09:21:27 2011
From: matthias.bolte at googlemail.com (Matthias Bolte)
Date: Sun, 3 Apr 2011 11:21:27 +0200
Subject: [libvirt] [PATCH 14/20] Remove PATH_MAX sized stack allocation from
virFileOpenTtyAt
In-Reply-To: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <1301822493-23013-15-git-send-email-matthias.bolte@googlemail.com>
---
src/util/util.c | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/src/util/util.c b/src/util/util.c
index 31feecc..c0391ad 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -1901,14 +1901,13 @@ int virFileOpenTtyAt(const char *ptmx,
}
if (ttyName) {
- char tempTtyName[PATH_MAX];
- if (ptsname_r(*ttymaster, tempTtyName, sizeof(tempTtyName)) < 0)
- goto cleanup;
-
- if ((*ttyName = strdup(tempTtyName)) == NULL) {
+ if (VIR_ALLOC_N(*ttyName, PATH_MAX) < 0) {
errno = ENOMEM;
goto cleanup;
}
+
+ if (ptsname_r(*ttymaster, *ttyName, PATH_MAX) < 0)
+ goto cleanup;
}
rc = 0;
--
1.7.0.4
From matthias.bolte at googlemail.com Sun Apr 3 09:21:26 2011
From: matthias.bolte at googlemail.com (Matthias Bolte)
Date: Sun, 3 Apr 2011 11:21:26 +0200
Subject: [libvirt] [PATCH 13/20] openvz: Remove several larger stack
allocations
In-Reply-To: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <1301822493-23013-14-git-send-email-matthias.bolte@googlemail.com>
Replace openvz_readline with getline in several places to get rid of stack
allocated buffers to hold lines.
openvzReadConfigParam allocates memory for return values instead of
expecting a preexisting buffer.
---
src/openvz/openvz_conf.c | 141 +++++++++++++++++++++++++++-----------------
src/openvz/openvz_conf.h | 2 +-
src/openvz/openvz_driver.c | 45 +++++++++-----
3 files changed, 117 insertions(+), 71 deletions(-)
diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c
index 2fcca68..88cd4c8 100644
--- a/src/openvz/openvz_conf.c
+++ b/src/openvz/openvz_conf.c
@@ -187,7 +187,7 @@ openvzReadNetworkConf(virDomainDefPtr def,
int veid) {
int ret;
virDomainNetDefPtr net = NULL;
- char temp[4096];
+ char *temp = NULL;
char *token, *saveptr = NULL;
/*parse routing network configuration*
@@ -195,7 +195,7 @@ openvzReadNetworkConf(virDomainDefPtr def,
* IP_ADDRESS="1.1.1.1 1.1.1.2"
* splited IPs by space
*/
- ret = openvzReadVPSConfigParam(veid, "IP_ADDRESS", temp, sizeof(temp));
+ ret = openvzReadVPSConfigParam(veid, "IP_ADDRESS", &temp);
if (ret < 0) {
openvzError(VIR_ERR_INTERNAL_ERROR,
_("Could not read 'IP_ADDRESS' from config for container %d"),
@@ -227,7 +227,7 @@ openvzReadNetworkConf(virDomainDefPtr def,
*NETIF="ifname=eth10,mac=00:18:51:C1:05:EE,host_ifname=veth105.10,host_mac=00:18:51:8F:D9:F3"
*devices splited by ';'
*/
- ret = openvzReadVPSConfigParam(veid, "NETIF", temp, sizeof(temp));
+ ret = openvzReadVPSConfigParam(veid, "NETIF", &temp);
if (ret < 0) {
openvzError(VIR_ERR_INTERNAL_ERROR,
_("Could not read 'NETIF' from config for container %d"),
@@ -316,10 +316,13 @@ openvzReadNetworkConf(virDomainDefPtr def,
}
}
+ VIR_FREE(temp);
+
return 0;
no_memory:
virReportOOMError();
error:
+ VIR_FREE(temp);
virDomainNetDefFree(net);
return -1;
}
@@ -364,10 +367,10 @@ openvzReadFSConf(virDomainDefPtr def,
int veid) {
int ret;
virDomainFSDefPtr fs = NULL;
- char* veid_str = NULL;
- char temp[100];
+ char *veid_str = NULL;
+ char *temp = NULL;
- ret = openvzReadVPSConfigParam(veid, "OSTEMPLATE", temp, sizeof(temp));
+ ret = openvzReadVPSConfigParam(veid, "OSTEMPLATE", &temp);
if (ret < 0) {
openvzError(VIR_ERR_INTERNAL_ERROR,
_("Could not read 'OSTEMPLATE' from config for container %d"),
@@ -381,7 +384,7 @@ openvzReadFSConf(virDomainDefPtr def,
fs->src = strdup(temp);
} else {
/* OSTEMPLATE was not found, VE was booted from a private dir directly */
- ret = openvzReadVPSConfigParam(veid, "VE_PRIVATE", temp, sizeof(temp));
+ ret = openvzReadVPSConfigParam(veid, "VE_PRIVATE", &temp);
if (ret <= 0) {
openvzError(VIR_ERR_INTERNAL_ERROR,
_("Could not read 'VE_PRIVATE' from config for container %d"),
@@ -411,10 +414,13 @@ openvzReadFSConf(virDomainDefPtr def,
def->fss[def->nfss++] = fs;
fs = NULL;
+ VIR_FREE(temp);
+
return 0;
no_memory:
virReportOOMError();
error:
+ VIR_FREE(temp);
virDomainFSDefFree(fs);
return -1;
}
@@ -439,7 +445,7 @@ int openvzLoadDomains(struct openvz_driver *driver) {
char *status;
char uuidstr[VIR_UUID_STRING_BUFLEN];
virDomainObjPtr dom = NULL;
- char temp[50];
+ char *temp = NULL;
char *outbuf = NULL;
char *line;
virCommandPtr cmd = NULL;
@@ -506,7 +512,7 @@ int openvzLoadDomains(struct openvz_driver *driver) {
if (!(dom->def->os.init = strdup("/sbin/init")))
goto no_memory;
- ret = openvzReadVPSConfigParam(veid, "CPUS", temp, sizeof(temp));
+ ret = openvzReadVPSConfigParam(veid, "CPUS", &temp);
if (ret < 0) {
openvzError(VIR_ERR_INTERNAL_ERROR,
_("Could not read config for container %d"),
@@ -534,6 +540,7 @@ int openvzLoadDomains(struct openvz_driver *driver) {
}
virCommandFree(cmd);
+ VIR_FREE(temp);
VIR_FREE(outbuf);
return 0;
@@ -543,6 +550,7 @@ int openvzLoadDomains(struct openvz_driver *driver) {
cleanup:
virCommandFree(cmd);
+ VIR_FREE(temp);
VIR_FREE(outbuf);
/* dom hasn't been shared yet, so unref should return 0 */
if (dom)
@@ -565,25 +573,26 @@ static int
openvzWriteConfigParam(const char * conf_file, const char *param, const char *value)
{
char * temp_file = NULL;
- int fd = -1, temp_fd = -1;
- char line[PATH_MAX];
+ int temp_fd = -1;
+ FILE *fp;
+ char *line = NULL;
+ size_t line_size = 0;
if (virAsprintf(&temp_file, "%s.tmp", conf_file)<0) {
virReportOOMError();
return -1;
}
- fd = open(conf_file, O_RDONLY);
- if (fd == -1)
+ fp = fopen(conf_file, "r");
+ if (fp == NULL)
goto error;
temp_fd = open(temp_file, O_WRONLY | O_CREAT | O_TRUNC, 0644);
if (temp_fd == -1) {
- VIR_FORCE_CLOSE(fd);
goto error;
}
while (1) {
- if (openvz_readline(fd, line, sizeof(line)) <= 0)
+ if (getline(&line, &line_size, fp) <= 0)
break;
if (!(STRPREFIX(line, param) && line[strlen(param)] == '=')) {
@@ -599,7 +608,7 @@ openvzWriteConfigParam(const char * conf_file, const char *param, const char *va
safewrite(temp_fd, "\"\n", 2) < 0)
goto error;
- if (VIR_CLOSE(fd) < 0)
+ if (VIR_FCLOSE(fp) < 0)
goto error;
if (VIR_CLOSE(temp_fd) < 0)
goto error;
@@ -607,10 +616,13 @@ openvzWriteConfigParam(const char * conf_file, const char *param, const char *va
if (rename(temp_file, conf_file) < 0)
goto error;
+ VIR_FREE(line);
+
return 0;
error:
- VIR_FORCE_CLOSE(fd);
+ VIR_FREE(line);
+ VIR_FORCE_FCLOSE(fp);
VIR_FORCE_CLOSE(temp_fd);
if (temp_file)
unlink(temp_file);
@@ -632,23 +644,29 @@ openvzWriteVPSConfigParam(int vpsid, const char *param, const char *value)
return ret;
}
+/*
+ * value will be freed before a new value is assigned to it, the caller is
+ * responsible for freeing it afterwards.
+ */
static int
-openvzReadConfigParam(const char * conf_file ,const char * param, char *value, int maxlen)
+openvzReadConfigParam(const char *conf_file, const char *param, char **value)
{
- char line[PATH_MAX];
- int ret, found = 0;
- int fd;
- char * sf, * token;
+ char *line = NULL;
+ size_t line_size = 0;
+ ssize_t ret;
+ FILE *fp;
+ int found = 0;
+ char *sf, *token;
char *saveptr = NULL;
value[0] = 0;
- fd = open(conf_file, O_RDONLY);
- if (fd == -1)
+ fp = fopen(conf_file, "r");
+ if (fp == NULL)
return -1;
while (1) {
- ret = openvz_readline(fd, line, sizeof(line));
+ ret = getline(&line, &line_size, fp);
if (ret <= 0)
break;
saveptr = NULL;
@@ -658,7 +676,9 @@ openvzReadConfigParam(const char * conf_file ,const char * param, char *value, i
if (sf[0] == '=' && sf[1] != '\0' ) {
sf++;
if ((token = strtok_r(sf,"\"\t\n", &saveptr)) != NULL) {
- if (virStrcpy(value, token, maxlen) == NULL) {
+ VIR_FREE(*value);
+ *value = strdup(token);
+ if (value == NULL) {
ret = -1;
break;
}
@@ -667,7 +687,8 @@ openvzReadConfigParam(const char * conf_file ,const char * param, char *value, i
}
}
}
- VIR_FORCE_CLOSE(fd);
+ VIR_FREE(line);
+ VIR_FORCE_FCLOSE(fp);
if (ret == 0 && found)
ret = 1;
@@ -676,14 +697,18 @@ openvzReadConfigParam(const char * conf_file ,const char * param, char *value, i
}
/*
-* Read parameter from container config
-* sample: 133, "OSTEMPLATE", value, 1024
-* return: -1 - error
-* 0 - don't found
-* 1 - OK
-*/
+ * Read parameter from container config
+ *
+ * value will be freed before a new value is assined to it, the caller is
+ * responsible for freeing it afterwards.
+ *
+ * sample: 133, "OSTEMPLATE", &value
+ * return: -1 - error
+ * 0 - don't found
+ * 1 - OK
+ */
int
-openvzReadVPSConfigParam(int vpsid ,const char * param, char *value, int maxlen)
+openvzReadVPSConfigParam(int vpsid, const char *param, char **value)
{
char *conf_file;
int ret;
@@ -691,7 +716,7 @@ openvzReadVPSConfigParam(int vpsid ,const char * param, char *value, int maxlen)
if (openvzLocateConfFile(vpsid, &conf_file, "conf") < 0)
return -1;
- ret = openvzReadConfigParam(conf_file, param, value, maxlen);
+ ret = openvzReadConfigParam(conf_file, param, value);
VIR_FREE(conf_file);
return ret;
}
@@ -699,21 +724,23 @@ openvzReadVPSConfigParam(int vpsid ,const char * param, char *value, int maxlen)
static int
openvz_copyfile(char* from_path, char* to_path)
{
- char line[PATH_MAX];
- int fd, copy_fd;
+ char *line = NULL;
+ size_t line_size = 0;
+ FILE *fp;
+ int copy_fd;
int bytes_read;
- fd = open(from_path, O_RDONLY);
- if (fd == -1)
+ fp = fopen(from_path, "r");
+ if (fp == NULL)
return -1;
copy_fd = open(to_path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
if (copy_fd == -1) {
- VIR_FORCE_CLOSE(fd);
+ VIR_FORCE_FCLOSE(fp);
return -1;
}
while (1) {
- if (openvz_readline(fd, line, sizeof(line)) <= 0)
+ if (getline(&line, &line_size, fp) <= 0)
break;
bytes_read = strlen(line);
@@ -721,15 +748,18 @@ openvz_copyfile(char* from_path, char* to_path)
goto error;
}
- if (VIR_CLOSE(fd) < 0)
+ if (VIR_FCLOSE(fp) < 0)
goto error;
if (VIR_CLOSE(copy_fd) < 0)
goto error;
+ VIR_FREE(line);
+
return 0;
error:
- VIR_FORCE_CLOSE(fd);
+ VIR_FREE(line);
+ VIR_FORCE_FCLOSE(fp);
VIR_FORCE_CLOSE(copy_fd);
return -1;
}
@@ -742,14 +772,13 @@ error:
int
openvzCopyDefaultConfig(int vpsid)
{
- char * confdir = NULL;
- char * default_conf_file = NULL;
- char configfile_value[PATH_MAX];
+ char *confdir = NULL;
+ char *default_conf_file = NULL;
+ char *configfile_value = NULL;
char *conf_file = NULL;
int ret = -1;
- if (openvzReadConfigParam(VZ_CONF_FILE, "CONFIGFILE", configfile_value,
- PATH_MAX) < 0)
+ if (openvzReadConfigParam(VZ_CONF_FILE, "CONFIGFILE", &configfile_value) < 0)
goto cleanup;
confdir = openvzLocateConfDir();
@@ -772,6 +801,7 @@ openvzCopyDefaultConfig(int vpsid)
cleanup:
VIR_FREE(confdir);
VIR_FREE(default_conf_file);
+ VIR_FREE(configfile_value);
VIR_FREE(conf_file);
return ret;
}
@@ -844,22 +874,24 @@ static int
openvzGetVPSUUID(int vpsid, char *uuidstr, size_t len)
{
char *conf_file;
- char line[1024];
+ char *line = NULL;
+ size_t line_size = 0;
+ ssize_t ret;
char *saveptr = NULL;
char *uuidbuf;
char *iden;
- int fd, ret;
+ FILE *fp;
int retval = -1;
if (openvzLocateConfFile(vpsid, &conf_file, "conf") < 0)
return -1;
- fd = open(conf_file, O_RDONLY);
- if (fd == -1)
+ fp = fopen(conf_file, "r");
+ if (fp == NULL)
goto cleanup;
while (1) {
- ret = openvz_readline(fd, line, sizeof(line));
+ ret = getline(&line, &line_size, fp);
if (ret == -1)
goto cleanup;
@@ -882,7 +914,8 @@ openvzGetVPSUUID(int vpsid, char *uuidstr, size_t len)
}
retval = 0;
cleanup:
- VIR_FORCE_CLOSE(fd);
+ VIR_FREE(line);
+ VIR_FORCE_FCLOSE(fp);
VIR_FREE(conf_file);
return retval;
diff --git a/src/openvz/openvz_conf.h b/src/openvz/openvz_conf.h
index 50bcb5e..4673fa6 100644
--- a/src/openvz/openvz_conf.h
+++ b/src/openvz/openvz_conf.h
@@ -55,7 +55,7 @@ struct openvz_driver {
int openvz_readline(int fd, char *ptr, int maxlen);
int openvzExtractVersion(struct openvz_driver *driver);
-int openvzReadVPSConfigParam(int vpsid ,const char * param, char *value, int maxlen);
+int openvzReadVPSConfigParam(int vpsid, const char *param, char **value);
int openvzWriteVPSConfigParam(int vpsid, const char *param, const char *value);
int openvzCopyDefaultConfig(int vpsid);
virCapsPtr openvzCapsInit(void);
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index fb30c37..c6fee3b 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -631,15 +631,16 @@ openvzGenerateVethName(int veid, char *dev_name_ve)
static char *
openvzGenerateContainerVethName(int veid)
{
- char temp[1024];
+ char *temp = NULL;
+ char *name = NULL;
/* try to get line "^NETIF=..." from config */
- if (openvzReadVPSConfigParam(veid, "NETIF", temp, sizeof(temp)) <= 0) {
- snprintf(temp, sizeof(temp), "eth0");
+ if (openvzReadVPSConfigParam(veid, "NETIF", &temp) <= 0) {
+ name = strdup("eth0");
} else {
char *saveptr;
- char *s;
- int max = 0;
+ char *s;
+ int max = 0;
/* get maximum interface number (actually, it is the last one) */
for (s=strtok_r(temp, ";", &saveptr); s; s=strtok_r(NULL, ";", &saveptr)) {
@@ -650,9 +651,16 @@ openvzGenerateContainerVethName(int veid)
}
/* set new name */
- snprintf(temp, sizeof(temp), "eth%d", max+1);
+ virAsprintf(&name, "eth%d", max + 1);
}
- return strdup(temp);
+
+ VIR_FREE(temp);
+
+ if (name == NULL) {
+ virReportOOMError();
+ }
+
+ return name;
}
static int
@@ -1125,7 +1133,7 @@ openvzDomainGetAutostart(virDomainPtr dom, int *autostart)
{
struct openvz_driver *driver = dom->conn->privateData;
virDomainObjPtr vm;
- char value[1024];
+ char *value = NULL;
int ret = -1;
openvzDriverLock(driver);
@@ -1138,7 +1146,7 @@ openvzDomainGetAutostart(virDomainPtr dom, int *autostart)
goto cleanup;
}
- if (openvzReadVPSConfigParam(strtoI(vm->def->name), "ONBOOT", value, sizeof(value)) < 0) {
+ if (openvzReadVPSConfigParam(strtoI(vm->def->name), "ONBOOT", &value) < 0) {
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not read container config"));
goto cleanup;
@@ -1150,6 +1158,8 @@ openvzDomainGetAutostart(virDomainPtr dom, int *autostart)
ret = 0;
cleanup:
+ VIR_FREE(value);
+
if (vm)
virDomainObjUnlock(vm);
return ret;
@@ -1464,12 +1474,14 @@ out:
return -1;
}
-static int openvzGetProcessInfo(unsigned long long *cpuTime, int vpsid) {
- int fd;
- char line[1024] ;
+static int openvzGetProcessInfo(unsigned long long *cpuTime, int vpsid)
+{
+ FILE *fp;
+ char *line = NULL;
+ size_t line_size = 0;
unsigned long long usertime, systime, nicetime;
int readvps = vpsid + 1; /* ensure readvps is initially different */
- int ret;
+ ssize_t ret;
/* read statistic from /proc/vz/vestat.
sample:
@@ -1479,12 +1491,12 @@ Version: 2.2
55 178 0 5340 59424597 542650441835148 other..
*/
- if ((fd = open("/proc/vz/vestat", O_RDONLY)) == -1)
+ if ((fp = fopen("/proc/vz/vestat", "r")) == NULL)
return -1;
/*search line with VEID=vpsid*/
while (1) {
- ret = openvz_readline(fd, line, sizeof(line));
+ ret = getline(&line, &line_size, fp);
if (ret <= 0)
break;
@@ -1499,7 +1511,8 @@ Version: 2.2
}
}
- VIR_FORCE_CLOSE(fd);
+ VIR_FREE(line);
+ VIR_FORCE_FCLOSE(fp);
if (ret < 0)
return -1;
--
1.7.0.4
From matthias.bolte at googlemail.com Sun Apr 3 09:21:28 2011
From: matthias.bolte at googlemail.com (Matthias Bolte)
Date: Sun, 3 Apr 2011 11:21:28 +0200
Subject: [libvirt] [PATCH 15/20] qemu: Remove PATH_MAX sized stack
allocation used in commandline building
In-Reply-To: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <1301822493-23013-16-git-send-email-matthias.bolte@googlemail.com>
---
src/qemu/qemu_command.c | 43 ++++++++++++++++++++++++++++++-------------
1 files changed, 30 insertions(+), 13 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 3138943..326a6b3 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3318,7 +3318,8 @@ qemuBuildCommandLine(virConnectPtr conn,
} else {
for (i = 0 ; i < def->ndisks ; i++) {
char dev[NAME_MAX];
- char file[PATH_MAX];
+ char *file;
+ const char *fmt;
virDomainDiskDefPtr disk = def->disks[i];
int j;
@@ -3368,9 +3369,13 @@ qemuBuildCommandLine(virConnectPtr conn,
goto error;
}
if (disk->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY)
- snprintf(file, PATH_MAX, "fat:floppy:%s", disk->src);
+ fmt = "fat:floppy:%s";
else
- snprintf(file, PATH_MAX, "fat:%s", disk->src);
+ fmt = "fat:%s";
+
+ if (virAsprintf(&file, fmt, disk->src) < 0) {
+ goto no_memory;
+ }
} else if (disk->type == VIR_DOMAIN_DISK_TYPE_NETWORK) {
switch (disk->protocol) {
case VIR_DOMAIN_DISK_PROTOCOL_NBD:
@@ -3379,11 +3384,15 @@ qemuBuildCommandLine(virConnectPtr conn,
_("NBD accepts only one host"));
goto error;
}
- snprintf(file, PATH_MAX, "nbd:%s:%s,",
- disk->hosts->name, disk->hosts->port);
+ if (virAsprintf(&file, "nbd:%s:%s,", disk->hosts->name,
+ disk->hosts->port) < 0) {
+ goto no_memory;
+ }
break;
case VIR_DOMAIN_DISK_PROTOCOL_RBD:
- snprintf(file, PATH_MAX, "rbd:%s,", disk->src);
+ if (virAsprintf(&file, "rbd:%s,", disk->src) < 0) {
+ goto no_memory;
+ }
for (j = 0 ; j < disk->nhosts ; j++) {
if (!has_rbd_hosts) {
virBufferAddLit(&rbd_hosts, "CEPH_ARGS=-m ");
@@ -3403,20 +3412,28 @@ qemuBuildCommandLine(virConnectPtr conn,
}
break;
case VIR_DOMAIN_DISK_PROTOCOL_SHEEPDOG:
- if (disk->nhosts == 0)
- snprintf(file, PATH_MAX, "sheepdog:%s,", disk->src);
- else
+ if (disk->nhosts == 0) {
+ if (virAsprintf(&file, "sheepdog:%s,", disk->src) < 0) {
+ goto no_memory;
+ }
+ } else {
/* only one host is supported now */
- snprintf(file, PATH_MAX, "sheepdog:%s:%s:%s,",
- disk->hosts->name, disk->hosts->port,
- disk->src);
+ if (virAsprintf(&file, "sheepdog:%s:%s:%s,",
+ disk->hosts->name, disk->hosts->port,
+ disk->src) < 0) {
+ goto no_memory;
+ }
+ }
break;
}
} else {
- snprintf(file, PATH_MAX, "%s", disk->src);
+ if (!(file = strdup(disk->src))) {
+ goto no_memory;
+ }
}
virCommandAddArgList(cmd, dev, file, NULL);
+ VIR_FREE(file);
}
}
--
1.7.0.4
From matthias.bolte at googlemail.com Sun Apr 3 09:21:29 2011
From: matthias.bolte at googlemail.com (Matthias Bolte)
Date: Sun, 3 Apr 2011 11:21:29 +0200
Subject: [libvirt] [PATCH 16/20] xen: Remove PATH_MAX sized stack allocation
from block stats code
In-Reply-To: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <1301822493-23013-17-git-send-email-matthias.bolte@googlemail.com>
---
src/xen/block_stats.c | 52 +++++++++++++++++++++++++-----------------------
1 files changed, 27 insertions(+), 25 deletions(-)
diff --git a/src/xen/block_stats.c b/src/xen/block_stats.c
index e7c80c9..6b4171d 100644
--- a/src/xen/block_stats.c
+++ b/src/xen/block_stats.c
@@ -113,34 +113,36 @@ read_stat (const char *path)
}
static int64_t
-read_bd_stat (int device, int domid, const char *str)
+read_bd_stat(int device, int domid, const char *str)
{
- char path[PATH_MAX];
+ static const char *paths[] = {
+ "/sys/bus/xen-backend/devices/vbd-%d-%d/statistics/%s",
+ "/sys/bus/xen-backend/devices/tap-%d-%d/statistics/%s",
+ "/sys/devices/xen-backend/vbd-%d-%d/statistics/%s",
+ "/sys/devices/xen-backend/tap-%d-%d/statistics/%s",
+ NULL
+ };
+
+ int i;
+ char *path;
int64_t r;
- snprintf (path, sizeof path,
- "/sys/bus/xen-backend/devices/vbd-%d-%d/statistics/%s",
- domid, device, str);
- r = read_stat (path);
- if (r >= 0) return r;
-
- snprintf (path, sizeof path,
- "/sys/bus/xen-backend/devices/tap-%d-%d/statistics/%s",
- domid, device, str);
- r = read_stat (path);
- if (r >= 0) return r;
-
- snprintf (path, sizeof path,
- "/sys/devices/xen-backend/vbd-%d-%d/statistics/%s",
- domid, device, str);
- r = read_stat (path);
- if (r >= 0) return r;
-
- snprintf (path, sizeof path,
- "/sys/devices/xen-backend/tap-%d-%d/statistics/%s",
- domid, device, str);
- r = read_stat (path);
- return r;
+ for (i = 0; paths[i] != NULL; ++i) {
+ if (virAsprintf(&path, paths[i], domid, device, str) < 0) {
+ virReportOOMError();
+ return -1;
+ }
+
+ r = read_stat(path);
+
+ VIR_FREE(path);
+
+ if (r >= 0) {
+ return r;
+ }
+ }
+
+ return -1;
}
/* In Xenstore, /local/domain/0/backend/vbd///state,
--
1.7.0.4
From matthias.bolte at googlemail.com Sun Apr 3 09:21:30 2011
From: matthias.bolte at googlemail.com (Matthias Bolte)
Date: Sun, 3 Apr 2011 11:21:30 +0200
Subject: [libvirt] [PATCH 17/20] storage: Remove PATH_MAX sized stack
allocation from iSCSI backend
In-Reply-To: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <1301822493-23013-18-git-send-email-matthias.bolte@googlemail.com>
---
src/storage/storage_backend_iscsi.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_backend_iscsi.c
index 6eff5f5..2e2e99e 100644
--- a/src/storage/storage_backend_iscsi.c
+++ b/src/storage/storage_backend_iscsi.c
@@ -409,12 +409,15 @@ static int
virStorageBackendISCSIFindLUs(virStoragePoolObjPtr pool,
const char *session)
{
- char sysfs_path[PATH_MAX];
+ char *sysfs_path;
int retval = 0;
uint32_t host;
- snprintf(sysfs_path, PATH_MAX,
- "/sys/class/iscsi_session/session%s/device", session);
+ if (virAsprintf(&sysfs_path,
+ "/sys/class/iscsi_session/session%s/device", session) < 0) {
+ virReportOOMError();
+ return -1;
+ }
if (virStorageBackendSCSIGetHostNumber(sysfs_path, &host) < 0) {
virReportSystemError(errno,
@@ -430,6 +433,8 @@ virStorageBackendISCSIFindLUs(virStoragePoolObjPtr pool,
retval = -1;
}
+ VIR_FREE(sysfs_path);
+
return retval;
}
--
1.7.0.4
From matthias.bolte at googlemail.com Sun Apr 3 09:21:31 2011
From: matthias.bolte at googlemail.com (Matthias Bolte)
Date: Sun, 3 Apr 2011 11:21:31 +0200
Subject: [libvirt] [PATCH 18/20] uml: Remove PATH_MAX sized stack allocation
from /proc parsing code
In-Reply-To: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <1301822493-23013-19-git-send-email-matthias.bolte@googlemail.com>
---
src/uml/uml_driver.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index e2bd5f2..33849a0 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -1036,21 +1036,25 @@ static char *umlGetCapabilities(virConnectPtr conn) {
-static int umlGetProcessInfo(unsigned long long *cpuTime, int pid) {
- char proc[PATH_MAX];
+static int umlGetProcessInfo(unsigned long long *cpuTime, int pid)
+{
+ char *proc;
FILE *pidinfo;
unsigned long long usertime, systime;
- if (snprintf(proc, sizeof(proc), "/proc/%d/stat", pid) >= (int)sizeof(proc)) {
+ if (virAsprintf(&proc, "/proc/%d/stat", pid) < 0) {
return -1;
}
if (!(pidinfo = fopen(proc, "r"))) {
/* VM probably shut down, so fake 0 */
*cpuTime = 0;
+ VIR_FREE(proc);
return 0;
}
+ VIR_FREE(proc);
+
if (fscanf(pidinfo, "%*d %*s %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %llu %llu", &usertime, &systime) != 2) {
umlDebug("not enough arg");
VIR_FORCE_FCLOSE(pidinfo);
--
1.7.0.4
From matthias.bolte at googlemail.com Sun Apr 3 09:21:32 2011
From: matthias.bolte at googlemail.com (Matthias Bolte)
Date: Sun, 3 Apr 2011 11:21:32 +0200
Subject: [libvirt] [PATCH 19/20] xend: Remove 4kb stack allocation
In-Reply-To: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <1301822493-23013-20-git-send-email-matthias.bolte@googlemail.com>
---
src/xen/xend_internal.c | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index 8859373..8b07a8a 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -279,11 +279,17 @@ istartswith(const char *haystack, const char *needle)
static int ATTRIBUTE_NONNULL (2)
xend_req(int fd, char **content)
{
- char buffer[4096];
+ char *buffer;
+ size_t buffer_size = 4096;
int content_length = 0;
int retcode = 0;
- while (sreads(fd, buffer, sizeof(buffer)) > 0) {
+ if (VIR_ALLOC_N(buffer, buffer_size) < 0) {
+ virReportOOMError();
+ return -1;
+ }
+
+ while (sreads(fd, buffer, buffer_size) > 0) {
if (STREQ(buffer, "\r\n"))
break;
@@ -293,6 +299,8 @@ xend_req(int fd, char **content)
retcode = atoi(buffer + 9);
}
+ VIR_FREE(buffer);
+
if (content_length > 0) {
ssize_t ret;
--
1.7.0.4
From matthias.bolte at googlemail.com Sun Apr 3 09:21:33 2011
From: matthias.bolte at googlemail.com (Matthias Bolte)
Date: Sun, 3 Apr 2011 11:21:33 +0200
Subject: [libvirt] [PATCH 20/20] Use virBufferPtr for sexpr2string instead
of manual buffer handling
In-Reply-To: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <1301822493-23013-21-git-send-email-matthias.bolte@googlemail.com>
Removes 4kb stack allocation in the XenD subdriver.
---
src/util/sexpr.c | 142 +++++++++++++++++++++++------------------------
src/util/sexpr.h | 3 +-
src/xen/xend_internal.c | 17 +++++-
3 files changed, 86 insertions(+), 76 deletions(-)
diff --git a/src/util/sexpr.c b/src/util/sexpr.c
index 7f14206..ae1692a 100644
--- a/src/util/sexpr.c
+++ b/src/util/sexpr.c
@@ -199,78 +199,56 @@ sexpr_append(struct sexpr *lst, const struct sexpr *value)
* sexpr2string:
* @sexpr: an S-Expression pointer
* @buffer: the output buffer
- * @n_buffer: the size of the buffer in bytes
*
* Serialize the S-Expression in the buffer.
- * Note that the output may be truncated if @n_buffer is too small
- * resulting in an unparseable value.
*
- * Returns the number of bytes used by the serialization in the buffer or
- * 0 in case of error.
+ * Returns 0 on success, -1 on error.
*/
-size_t
-sexpr2string(const struct sexpr * sexpr, char *buffer, size_t n_buffer)
+int
+sexpr2string(const struct sexpr *sexpr, virBufferPtr buffer)
{
- size_t ret = 0, tmp;
-
- if ((sexpr == NULL) || (buffer == NULL) || (n_buffer <= 0))
- return (0);
+ if ((sexpr == NULL) || (buffer == NULL))
+ return -1;
switch (sexpr->kind) {
- case SEXPR_CONS:
- tmp = snprintf(buffer + ret, n_buffer - ret, "(");
- if (tmp == 0)
- goto error;
- ret += tmp;
- tmp = sexpr2string(sexpr->u.s.car, buffer + ret, n_buffer - ret);
- if (tmp == 0)
- goto error;
- ret += tmp;
- 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->u.s.car, buffer + ret, n_buffer - ret);
- if (tmp == 0)
- goto error;
- ret += tmp;
- }
- tmp = snprintf(buffer + ret, n_buffer - ret, ")");
- if (tmp == 0)
- goto error;
- ret += tmp;
- break;
- case SEXPR_VALUE:
- if (strchr(sexpr->u.value, ' ') ||
- strchr(sexpr->u.value, ')') ||
- strchr(sexpr->u.value, '('))
- tmp = snprintf(buffer + ret, n_buffer - ret, "'%s'",
- sexpr->u.value);
- else
- tmp = snprintf(buffer + ret, n_buffer - ret, "%s",
- sexpr->u.value);
- if (tmp == 0)
- goto error;
- ret += tmp;
- break;
- case SEXPR_NIL:
- tmp = snprintf(buffer + ret, n_buffer - ret, "()");
- if (tmp == 0)
- goto error;
- ret += tmp;
- break;
- default:
+ case SEXPR_CONS:
+ virBufferAddChar(buffer, '(');
+
+ if (sexpr2string(sexpr->u.s.car, buffer) < 0)
goto error;
+
+ while (sexpr->u.s.cdr->kind != SEXPR_NIL) {
+ sexpr = sexpr->u.s.cdr;
+
+ virBufferAddChar(buffer, ' ');
+
+ if (sexpr2string(sexpr->u.s.car, buffer) < 0)
+ goto error;
+ }
+
+ virBufferAddChar(buffer, ')');
+ break;
+ case SEXPR_VALUE:
+ if (strchr(sexpr->u.value, ' ') ||
+ strchr(sexpr->u.value, ')') ||
+ strchr(sexpr->u.value, '('))
+ virBufferVSprintf(buffer, "'%s'", sexpr->u.value);
+ else
+ virBufferVSprintf(buffer, "%s", sexpr->u.value);
+
+ break;
+ case SEXPR_NIL:
+ virBufferAddLit(buffer, "()");
+ break;
+ default:
+ goto error;
}
- return (ret);
+ return 0;
+
error:
- buffer[n_buffer - 1] = 0;
- virSexprError(VIR_ERR_SEXPR_SERIAL, "%s", buffer);
- return (0);
+ virSexprError(VIR_ERR_SEXPR_SERIAL, NULL);
+ return -1;
}
#define IS_SPACE(c) ((c == 0x20) || (c == 0x9) || (c == 0xD) || (c == 0xA))
@@ -413,22 +391,28 @@ string2sexpr(const char *buffer)
static struct sexpr *
sexpr_lookup_key(const struct sexpr *sexpr, const char *node)
{
- char buffer[4096], *ptr, *token;
+ struct sexpr *result = NULL;
+ char *buffer, *ptr, *token;
if ((node == NULL) || (sexpr == NULL))
- return (NULL);
+ return NULL;
- snprintf(buffer, sizeof(buffer), "%s", node);
+ buffer = strdup(node);
+
+ if (buffer == NULL) {
+ virReportOOMError();
+ return NULL;
+ }
ptr = buffer;
token = strsep(&ptr, "/");
if (sexpr->kind != SEXPR_CONS || sexpr->u.s.car->kind != SEXPR_VALUE) {
- return NULL;
+ goto cleanup;
}
if (STRNEQ(sexpr->u.s.car->u.value, token)) {
- return NULL;
+ goto cleanup;
}
for (token = strsep(&ptr, "/"); token; token = strsep(&ptr, "/")) {
@@ -454,10 +438,15 @@ sexpr_lookup_key(const struct sexpr *sexpr, const char *node)
}
if (token != NULL) {
- return NULL;
+ goto cleanup;
}
- return (struct sexpr *) sexpr;
+ result = (struct sexpr *) sexpr;
+
+cleanup:
+ VIR_FREE(buffer);
+
+ return result;
}
/**
@@ -550,21 +539,30 @@ int sexpr_node_copy(const struct sexpr *sexpr, const char *node, char **dst)
* @... extra data to build the path
*
* Search a node value in the S-Expression based on its path
- * NOTE: path are limited to 4096 bytes.
*
* Returns the value of the node or NULL if not found.
*/
const char *
sexpr_fmt_node(const struct sexpr *sexpr, const char *fmt, ...)
{
+ int result;
va_list ap;
- char node[4096];
+ char *node;
+ const char *value;
va_start(ap, fmt);
- vsnprintf(node, sizeof(node), fmt, ap);
+ result = virVasprintf(&node, fmt, ap);
va_end(ap);
- return sexpr_node(sexpr, node);
+ if (result < 0) {
+ return NULL;
+ }
+
+ value = sexpr_node(sexpr, node);
+
+ VIR_FREE(node);
+
+ return value;
}
/**
diff --git a/src/util/sexpr.h b/src/util/sexpr.h
index dc6687d..8dfd89a 100644
--- a/src/util/sexpr.h
+++ b/src/util/sexpr.h
@@ -14,6 +14,7 @@
# define _LIBVIR_SEXPR_H_
# include "internal.h"
+# include "buf.h"
# include
# include
@@ -36,7 +37,7 @@ struct sexpr {
};
/* conversion to/from strings */
-size_t sexpr2string(const struct sexpr *sexpr, char *buffer, size_t n_buffer);
+int sexpr2string(const struct sexpr *sexpr, virBufferPtr buffer);
struct sexpr *string2sexpr(const char *buffer);
/* constructors and destructors */
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index 8b07a8a..04122ba 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -3023,7 +3023,8 @@ xenDaemonDomainSetAutostart(virDomainPtr domain,
int autostart)
{
struct sexpr *root, *autonode;
- char buf[4096];
+ virBuffer buffer = VIR_BUFFER_INITIALIZER;
+ char *content = NULL;
int ret = -1;
xenUnifiedPrivatePtr priv;
@@ -3065,12 +3066,20 @@ xenDaemonDomainSetAutostart(virDomainPtr domain,
goto error;
}
- if (sexpr2string(root, buf, sizeof(buf)) == 0) {
+ if (sexpr2string(root, &buffer) < 0) {
virXendError(VIR_ERR_INTERNAL_ERROR,
"%s", _("sexpr2string failed"));
goto error;
}
- if (xend_op(domain->conn, "", "op", "new", "config", buf, NULL) != 0) {
+
+ if (virBufferError(&buffer)) {
+ virReportOOMError();
+ goto error;
+ }
+
+ content = virBufferContentAndReset(&buffer);
+
+ if (xend_op(domain->conn, "", "op", "new", "config", content, NULL) != 0) {
virXendError(VIR_ERR_XEN_CALL,
"%s", _("Failed to redefine sexpr"));
goto error;
@@ -3083,6 +3092,8 @@ xenDaemonDomainSetAutostart(virDomainPtr domain,
ret = 0;
error:
+ virBufferFreeAndReset(&buffer);
+ VIR_FREE(content);
sexpr_free(root);
return ret;
}
--
1.7.0.4
From stefanha at gmail.com Sun Apr 3 11:57:02 2011
From: stefanha at gmail.com (Stefan Hajnoczi)
Date: Sun, 3 Apr 2011 12:57:02 +0100
Subject: [libvirt] [Qemu-devel] [PATCH v2 3/3] raw-posix: Re-open host
CD-ROM after media change
In-Reply-To: <1301425482-8722-4-git-send-email-stefanha@linux.vnet.ibm.com>
References: <1301425482-8722-1-git-send-email-stefanha@linux.vnet.ibm.com>
<1301425482-8722-4-git-send-email-stefanha@linux.vnet.ibm.com>
Message-ID:
On Tue, Mar 29, 2011 at 8:04 PM, Stefan Hajnoczi
wrote:
> Piggy-back on the guest CD-ROM polling to poll on the host. ?Open and
> close the host CD-ROM file descriptor to ensure we read the new size and
> not a stale size.
>
> Two things are going on here:
>
> 1. If hald/udisks is not already polling CD-ROMs on the host then
> ? re-opening the CD-ROM causes the host to read the new medium's size.
>
> 2. There is a bug in Linux which means the CD-ROM file descriptor must
> ? be re-opened in order for lseek(2) to see the new size. ?The
> ? inode size gets out of sync with the underlying device (which you can
> ? confirm by checking that /sys/block/sr0/size and lseek(2) do not
> ? match after media change). ?I have raised this with the
> ? maintainers but we need a workaround for the foreseeable future.
>
> Note that these changes are all in a #ifdef __linux__ section.
>
> Signed-off-by: Stefan Hajnoczi
> ---
> ?block/raw-posix.c | ? 26 ++++++++++++++++++++++----
> ?1 files changed, 22 insertions(+), 4 deletions(-)
>
> diff --git a/block/raw-posix.c b/block/raw-posix.c
> index 6b72470..8b5205c 100644
> --- a/block/raw-posix.c
> +++ b/block/raw-posix.c
> @@ -1238,10 +1238,28 @@ static int cdrom_is_inserted(BlockDriverState *bs)
> ? ? BDRVRawState *s = bs->opaque;
> ? ? int ret;
>
> - ? ?ret = ioctl(s->fd, CDROM_DRIVE_STATUS, CDSL_CURRENT);
> - ? ?if (ret == CDS_DISC_OK)
> - ? ? ? ?return 1;
> - ? ?return 0;
> + ? ?/*
> + ? ? * Close the file descriptor if no medium is present and open it to poll
> + ? ? * again. ?This ensures the medium size is refreshed. ?If the file
> + ? ? * descriptor is kept open the size can become stale. ?This is essentially
> + ? ? * replicating CD-ROM polling but is driven by the guest. ?As the guest
> + ? ? * polls, we poll the host.
> + ? ? */
> +
> + ? ?if (s->fd == -1) {
> + ? ? ? ?s->fd = qemu_open(bs->filename, s->open_flags, 0644);
> + ? ? ? ?if (s->fd < 0) {
> + ? ? ? ? ? ?return 0;
> + ? ? ? ?}
> + ? ?}
> +
> + ? ?ret = (ioctl(s->fd, CDROM_DRIVE_STATUS, CDSL_CURRENT) == CDS_DISC_OK);
> +
> + ? ?if (!ret) {
> + ? ? ? ?close(s->fd);
> + ? ? ? ?s->fd = -1;
> + ? ?}
> + ? ?return ret;
> ?}
>
> ?static int cdrom_eject(BlockDriverState *bs, int eject_flag)
> --
> 1.7.4.1
>
>
>
There is an issue with reopening host devices in QEMU when running
under libvirt. It appears that libvirt chowns image files (including
device nodes) so that the launched QEMU process can access them.
Unfortunately after media change on host devices udev will reset the
ownership of the device node. This causes open(2) to fail with EACCES
since the QEMU process does not have the right uid/gid/groups and
libvirt is unaware that the file's ownership has changed.
In order for media change to work with Linux host CD-ROM it is
necessary to reopen the file (otherwise the inode size will not
refresh, this is an issue with existing kernels).
How can libvirt's security model be made to support this case? In
theory udev could be temporarily configured with libvirt permissions
for the CD-ROM device while passed through to the guest, but is that
feasible?
Stefan
From matthias.bolte at googlemail.com Sun Apr 3 12:19:14 2011
From: matthias.bolte at googlemail.com (Matthias Bolte)
Date: Sun, 3 Apr 2011 14:19:14 +0200
Subject: [libvirt] [PATCH] vmx: Use case-insensitive compare functions for
all content
Message-ID: <20110403121914.GA22826@sbox>
---
src/vmx/vmx.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 9f4d5fb..9a482ef 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -730,7 +730,7 @@ virVMXGetConfigLong(virConfPtr conf, const char *name, long long *number,
}
}
- if (STREQ(value->str, "unlimited")) {
+ if (STRCASEEQ(value->str, "unlimited")) {
*number = -1;
} else if (virStrToLong_ll(value->str, NULL, 10, number) < 0) {
VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
@@ -1385,7 +1385,7 @@ virVMXParseConfig(virVMXContext *ctx, virCapsPtr caps, const char *vmx)
goto cleanup;
}
- if (sched_cpu_affinity != NULL && STRNEQ(sched_cpu_affinity, "all")) {
+ if (sched_cpu_affinity != NULL && STRCASENEQ(sched_cpu_affinity, "all")) {
const char *current = sched_cpu_affinity;
int number, count = 0;
@@ -2107,7 +2107,7 @@ virVMXParseDisk(virVMXContext *ctx, virCapsPtr caps, virConfPtr conf,
goto cleanup;
}
} else if (virFileHasSuffix(fileName, ".iso") ||
- STREQ(deviceType, "atapi-cdrom")) {
+ STRCASEEQ(deviceType, "atapi-cdrom")) {
/*
* This function was called in order to parse a harddisk device,
* but .iso files and 'atapi-cdrom' devices are for CDROM devices
@@ -2146,7 +2146,7 @@ virVMXParseDisk(virVMXContext *ctx, virCapsPtr caps, virConfPtr conf,
* handle it.
*/
goto ignore;
- } else if (STREQ(deviceType, "atapi-cdrom")) {
+ } else if (STRCASEEQ(deviceType, "atapi-cdrom")) {
(*def)->type = VIR_DOMAIN_DISK_TYPE_BLOCK;
(*def)->src = fileName;
@@ -2174,7 +2174,7 @@ virVMXParseDisk(virVMXContext *ctx, virCapsPtr caps, virConfPtr conf,
if ((*def)->src == NULL) {
goto cleanup;
}
- } else if (fileType != NULL && STREQ(fileType, "device")) {
+ } else if (fileType != NULL && STRCASEEQ(fileType, "device")) {
(*def)->type = VIR_DOMAIN_DISK_TYPE_BLOCK;
(*def)->src = fileName;
--
1.7.0.4
From matthias.bolte at googlemail.com Sun Apr 3 12:43:55 2011
From: matthias.bolte at googlemail.com (Matthias Bolte)
Date: Sun, 3 Apr 2011 14:43:55 +0200
Subject: [libvirt] [PATCH] vmx: Support persistent CPU shares
Message-ID: <20110403124355.GA22943@sbox>
---
src/vmx/vmx.c | 43 ++++++++++++++++++++++
tests/vmx2xmldata/vmx2xml-case-insensitive-1.vmx | 2 +-
tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml | 3 ++
tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml | 3 ++
tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.vmx | 2 +-
tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.xml | 3 ++
tests/vmx2xmldata/vmx2xml-esx-in-the-wild-4.xml | 3 ++
tests/vmx2xmldata/vmx2xml-esx-in-the-wild-5.xml | 3 ++
tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.vmx | 1 +
tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.xml | 3 ++
tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.vmx | 1 +
tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.xml | 3 ++
tests/xml2vmxdata/xml2vmx-esx-in-the-wild-5.vmx | 1 +
tests/xml2vmxdata/xml2vmx-esx-in-the-wild-5.xml | 3 ++
14 files changed, 72 insertions(+), 2 deletions(-)
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 9a482ef..b0d3218 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -55,6 +55,8 @@ def->mem.cur_balloon = <=> sched.mem.max = "mem.min_guarantee = <=> sched.mem.minsize = "" # defaults to 0
def->maxvcpus = <=> numvcpus = "" # must be 1 or a multiple of 2, defaults to 1
def->cpumask = <=> sched.cpu.affinity = ""
+def->cputune.shares = <=> sched.cpu.shares = "" # with handling for special values
+ # "high", "normal", "low"
@@ -1200,6 +1202,7 @@ virVMXParseConfig(virVMXContext *ctx, virCapsPtr caps, const char *vmx)
long long sched_mem_minsize = 0;
long long numvcpus = 0;
char *sched_cpu_affinity = NULL;
+ char *sched_cpu_shares = NULL;
char *guestOS = NULL;
bool smbios_reflecthost = false;
int controller;
@@ -1449,6 +1452,30 @@ virVMXParseConfig(virVMXContext *ctx, virCapsPtr caps, const char *vmx)
}
}
+ /* vmx:sched.cpu.shares -> def:cputune.shares */
+ if (virVMXGetConfigString(conf, "sched.cpu.shares", &sched_cpu_shares,
+ true) < 0) {
+ goto cleanup;
+ }
+
+ if (sched_cpu_shares != NULL) {
+ /* See http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.SharesInfo.Level.html */
+ if (STRCASEEQ(sched_cpu_shares, "low")) {
+ def->cputune.shares = def->vcpus * 500;
+ } else if (STRCASEEQ(sched_cpu_shares, "normal")) {
+ def->cputune.shares = def->vcpus * 1000;
+ } else if (STRCASEEQ(sched_cpu_shares, "high")) {
+ def->cputune.shares = def->vcpus * 2000;
+ } else if (virStrToLong_ul(sched_cpu_shares, NULL, 10,
+ &def->cputune.shares) < 0) {
+ VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("Expecting VMX entry 'sched.cpu.shares' to be an "
+ "unsigned integer or 'low', 'normal' or 'high' but "
+ "found '%s'"), sched_cpu_shares);
+ goto cleanup;
+ }
+ }
+
/* def:lifecycle */
def->onReboot = VIR_DOMAIN_LIFECYCLE_RESTART;
def->onPoweroff = VIR_DOMAIN_LIFECYCLE_DESTROY;
@@ -1715,6 +1742,7 @@ virVMXParseConfig(virVMXContext *ctx, virCapsPtr caps, const char *vmx)
virConfFree(conf);
VIR_FREE(encoding);
VIR_FREE(sched_cpu_affinity);
+ VIR_FREE(sched_cpu_shares);
VIR_FREE(guestOS);
return def;
@@ -2998,6 +3026,21 @@ virVMXFormatConfig(virVMXContext *ctx, virCapsPtr caps, virDomainDefPtr def,
virBufferAddLit(&buffer, "\"\n");
}
+ /* def:cputune.shares -> vmx:sched.cpu.shares */
+ if (def->cputune.shares > 0) {
+ /* See http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.SharesInfo.Level.html */
+ if (def->cputune.shares == def->vcpus * 500) {
+ virBufferAddLit(&buffer, "sched.cpu.shares = \"low\"\n");
+ } else if (def->cputune.shares == def->vcpus * 1000) {
+ virBufferAddLit(&buffer, "sched.cpu.shares = \"normal\"\n");
+ } else if (def->cputune.shares == def->vcpus * 2000) {
+ virBufferAddLit(&buffer, "sched.cpu.shares = \"high\"\n");
+ } else {
+ virBufferVSprintf(&buffer, "sched.cpu.shares = \"%lu\"\n",
+ def->cputune.shares);
+ }
+ }
+
/* def:graphics */
for (i = 0; i < def->ngraphics; ++i) {
switch (def->graphics[i]->type) {
diff --git a/tests/vmx2xmldata/vmx2xml-case-insensitive-1.vmx b/tests/vmx2xmldata/vmx2xml-case-insensitive-1.vmx
index bd36cf8..8641c5c 100644
--- a/tests/vmx2xmldata/vmx2xml-case-insensitive-1.vmx
+++ b/tests/vmx2xmldata/vmx2xml-case-insensitive-1.vmx
@@ -35,7 +35,7 @@ UUID.BIOS = "50 11 5E 16 9B DC 49 D7-F1 71 53 C4 D7 F9 17 10"
SNAPSHOT.ACTION = "KEEP"
SCHED.CPU.MIN = "0"
SCHED.CPU.UNITS = "MHZ"
-SCHED.CPU.SHARES = "NORMAL"
+SCHED.CPU.SHARES = "4223"
SCHED.MEM.MINSIZE = "0"
SCHED.MEM.SHARES = "NORMAL"
TOOLSCRIPTS.AFTERPOWERON = "TRUE"
diff --git a/tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml b/tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml
index 7a5ff5b..ef6edd8 100644
--- a/tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml
+++ b/tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml
@@ -4,6 +4,9 @@
1048576
1048576
1
+
+ 4223
+
hvm
diff --git a/tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml b/tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml
index 18d6461..02771b9 100644
--- a/tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml
+++ b/tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml
@@ -4,6 +4,9 @@
1048576
1048576
1
+
+ 1000
+
hvm
diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.vmx b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.vmx
index 4392062..78741ae 100644
--- a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.vmx
+++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.vmx
@@ -36,7 +36,7 @@ uuid.bios = "50 11 5e 16 9b dc 49 d7-f1 71 53 c4 d7 f9 17 10"
snapshot.action = "keep"
sched.cpu.min = "0"
sched.cpu.units = "mhz"
-sched.cpu.shares = "normal"
+sched.cpu.shares = "low"
sched.mem.minsize = "0"
sched.mem.shares = "normal"
toolScripts.afterPowerOn = "true"
diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.xml b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.xml
index 5e67e74..e8f9307 100644
--- a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.xml
+++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.xml
@@ -4,6 +4,9 @@
1048576
1048576
1
+
+ 500
+
hvm
diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-4.xml b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-4.xml
index 419df51..2824d66 100644
--- a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-4.xml
+++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-4.xml
@@ -4,6 +4,9 @@
524288
524288
1
+
+ 1000
+
hvm
diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-5.xml b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-5.xml
index 0040163..6f0a9d1 100644
--- a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-5.xml
+++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-5.xml
@@ -8,6 +8,9 @@
262144
2
+
+ 2000
+
hvm
diff --git a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.vmx b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.vmx
index e72ca80..9059197 100644
--- a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.vmx
+++ b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.vmx
@@ -6,6 +6,7 @@ uuid.bios = "50 11 5e 16 9b dc 49 d7-f1 71 53 c4 d7 f9 17 10"
displayName = "Fedora11"
memsize = "1024"
numvcpus = "1"
+sched.cpu.shares = "low"
scsi0.present = "true"
scsi0.virtualDev = "lsilogic"
scsi0:0.present = "true"
diff --git a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.xml b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.xml
index 3f4ff88..ea59778 100644
--- a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.xml
+++ b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.xml
@@ -4,6 +4,9 @@
1048576
1048576
1
+
+ 500
+
hvm
diff --git a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.vmx b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.vmx
index 627fcfb..504997f 100644
--- a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.vmx
+++ b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.vmx
@@ -6,6 +6,7 @@ uuid.bios = "56 4d 9b ef ac d9 b4 e0-c8 f0 ae a8 b9 10 35 15"
displayName = "virtMonServ1"
memsize = "512"
numvcpus = "1"
+sched.cpu.shares = "normal"
scsi0.present = "true"
scsi0.virtualDev = "lsilogic"
scsi0:0.present = "true"
diff --git a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.xml b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.xml
index 078753a..443aacd 100644
--- a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.xml
+++ b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.xml
@@ -4,6 +4,9 @@
524288
524288
1
+
+ 1000
+
hvm
diff --git a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-5.vmx b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-5.vmx
index cc2485f..2e3b856 100644
--- a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-5.vmx
+++ b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-5.vmx
@@ -8,6 +8,7 @@ annotation = "Centos 5.5 64bit Server"
memsize = "2048"
sched.mem.minsize = "256"
numvcpus = "2"
+sched.cpu.shares = "normal"
scsi0.present = "true"
scsi0.virtualDev = "lsilogic"
scsi0:0.present = "true"
diff --git a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-5.xml b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-5.xml
index d55bf6b..f28c15e 100644
--- a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-5.xml
+++ b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-5.xml
@@ -8,6 +8,9 @@
262144
2
+
+ 2000
+
hvm
--
1.7.0.4
From blauwirbel at gmail.com Sun Apr 3 13:12:08 2011
From: blauwirbel at gmail.com (Blue Swirl)
Date: Sun, 3 Apr 2011 16:12:08 +0300
Subject: [libvirt] [Qemu-devel] [PATCH v2 3/3] raw-posix: Re-open host
CD-ROM after media change
In-Reply-To:
References: <1301425482-8722-1-git-send-email-stefanha@linux.vnet.ibm.com>
<1301425482-8722-4-git-send-email-stefanha@linux.vnet.ibm.com>
Message-ID:
On Sun, Apr 3, 2011 at 2:57 PM, Stefan Hajnoczi wrote:
> On Tue, Mar 29, 2011 at 8:04 PM, Stefan Hajnoczi
> wrote:
>> Piggy-back on the guest CD-ROM polling to poll on the host. ?Open and
>> close the host CD-ROM file descriptor to ensure we read the new size and
>> not a stale size.
>>
>> Two things are going on here:
>>
>> 1. If hald/udisks is not already polling CD-ROMs on the host then
>> ? re-opening the CD-ROM causes the host to read the new medium's size.
>>
>> 2. There is a bug in Linux which means the CD-ROM file descriptor must
>> ? be re-opened in order for lseek(2) to see the new size. ?The
>> ? inode size gets out of sync with the underlying device (which you can
>> ? confirm by checking that /sys/block/sr0/size and lseek(2) do not
>> ? match after media change). ?I have raised this with the
>> ? maintainers but we need a workaround for the foreseeable future.
>>
>> Note that these changes are all in a #ifdef __linux__ section.
>>
>> Signed-off-by: Stefan Hajnoczi
>> ---
>> ?block/raw-posix.c | ? 26 ++++++++++++++++++++++----
>> ?1 files changed, 22 insertions(+), 4 deletions(-)
>>
>> diff --git a/block/raw-posix.c b/block/raw-posix.c
>> index 6b72470..8b5205c 100644
>> --- a/block/raw-posix.c
>> +++ b/block/raw-posix.c
>> @@ -1238,10 +1238,28 @@ static int cdrom_is_inserted(BlockDriverState *bs)
>> ? ? BDRVRawState *s = bs->opaque;
>> ? ? int ret;
>>
>> - ? ?ret = ioctl(s->fd, CDROM_DRIVE_STATUS, CDSL_CURRENT);
>> - ? ?if (ret == CDS_DISC_OK)
>> - ? ? ? ?return 1;
>> - ? ?return 0;
>> + ? ?/*
>> + ? ? * Close the file descriptor if no medium is present and open it to poll
>> + ? ? * again. ?This ensures the medium size is refreshed. ?If the file
>> + ? ? * descriptor is kept open the size can become stale. ?This is essentially
>> + ? ? * replicating CD-ROM polling but is driven by the guest. ?As the guest
>> + ? ? * polls, we poll the host.
>> + ? ? */
>> +
>> + ? ?if (s->fd == -1) {
>> + ? ? ? ?s->fd = qemu_open(bs->filename, s->open_flags, 0644);
>> + ? ? ? ?if (s->fd < 0) {
>> + ? ? ? ? ? ?return 0;
>> + ? ? ? ?}
>> + ? ?}
>> +
>> + ? ?ret = (ioctl(s->fd, CDROM_DRIVE_STATUS, CDSL_CURRENT) == CDS_DISC_OK);
>> +
>> + ? ?if (!ret) {
>> + ? ? ? ?close(s->fd);
>> + ? ? ? ?s->fd = -1;
>> + ? ?}
>> + ? ?return ret;
>> ?}
>>
>> ?static int cdrom_eject(BlockDriverState *bs, int eject_flag)
>> --
>> 1.7.4.1
>>
>>
>>
>
> There is an issue with reopening host devices in QEMU when running
> under libvirt. ?It appears that libvirt chowns image files (including
> device nodes) so that the launched QEMU process can access them.
>
> Unfortunately after media change on host devices udev will reset the
> ownership of the device node. ?This causes open(2) to fail with EACCES
> since the QEMU process does not have the right uid/gid/groups and
> libvirt is unaware that the file's ownership has changed.
>
> In order for media change to work with Linux host CD-ROM it is
> necessary to reopen the file (otherwise the inode size will not
> refresh, this is an issue with existing kernels).
>
> How can libvirt's security model be made to support this case? ?In
> theory udev could be temporarily configured with libvirt permissions
> for the CD-ROM device while passed through to the guest, but is that
> feasible?
How about something like this: Add an explicit reopen method to
BlockDriver. Make a special block device for passed file descriptors.
Pass descriptors in libvirt for CD-ROMs instead of the device paths.
The reopen method for file descriptors should notify libvirt about
need to pass a reopened descriptor and then block all accesses until a
new descriptor is available. This should also solve your earlier
problem.
From stefanha at gmail.com Sun Apr 3 18:06:17 2011
From: stefanha at gmail.com (Stefan Hajnoczi)
Date: Sun, 3 Apr 2011 19:06:17 +0100
Subject: [libvirt] [Qemu-devel] [PATCH v2 3/3] raw-posix: Re-open host
CD-ROM after media change
In-Reply-To:
References: <1301425482-8722-1-git-send-email-stefanha@linux.vnet.ibm.com>
<1301425482-8722-4-git-send-email-stefanha@linux.vnet.ibm.com>
Message-ID:
On Sun, Apr 3, 2011 at 2:12 PM, Blue Swirl wrote:
> On Sun, Apr 3, 2011 at 2:57 PM, Stefan Hajnoczi wrote:
>> On Tue, Mar 29, 2011 at 8:04 PM, Stefan Hajnoczi
>> wrote:
>>> Piggy-back on the guest CD-ROM polling to poll on the host. ?Open and
>>> close the host CD-ROM file descriptor to ensure we read the new size and
>>> not a stale size.
>>>
>>> Two things are going on here:
>>>
>>> 1. If hald/udisks is not already polling CD-ROMs on the host then
>>> ? re-opening the CD-ROM causes the host to read the new medium's size.
>>>
>>> 2. There is a bug in Linux which means the CD-ROM file descriptor must
>>> ? be re-opened in order for lseek(2) to see the new size. ?The
>>> ? inode size gets out of sync with the underlying device (which you can
>>> ? confirm by checking that /sys/block/sr0/size and lseek(2) do not
>>> ? match after media change). ?I have raised this with the
>>> ? maintainers but we need a workaround for the foreseeable future.
>>>
>>> Note that these changes are all in a #ifdef __linux__ section.
>>>
>>> Signed-off-by: Stefan Hajnoczi
>>> ---
>>> ?block/raw-posix.c | ? 26 ++++++++++++++++++++++----
>>> ?1 files changed, 22 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/block/raw-posix.c b/block/raw-posix.c
>>> index 6b72470..8b5205c 100644
>>> --- a/block/raw-posix.c
>>> +++ b/block/raw-posix.c
>>> @@ -1238,10 +1238,28 @@ static int cdrom_is_inserted(BlockDriverState *bs)
>>> ? ? BDRVRawState *s = bs->opaque;
>>> ? ? int ret;
>>>
>>> - ? ?ret = ioctl(s->fd, CDROM_DRIVE_STATUS, CDSL_CURRENT);
>>> - ? ?if (ret == CDS_DISC_OK)
>>> - ? ? ? ?return 1;
>>> - ? ?return 0;
>>> + ? ?/*
>>> + ? ? * Close the file descriptor if no medium is present and open it to poll
>>> + ? ? * again. ?This ensures the medium size is refreshed. ?If the file
>>> + ? ? * descriptor is kept open the size can become stale. ?This is essentially
>>> + ? ? * replicating CD-ROM polling but is driven by the guest. ?As the guest
>>> + ? ? * polls, we poll the host.
>>> + ? ? */
>>> +
>>> + ? ?if (s->fd == -1) {
>>> + ? ? ? ?s->fd = qemu_open(bs->filename, s->open_flags, 0644);
>>> + ? ? ? ?if (s->fd < 0) {
>>> + ? ? ? ? ? ?return 0;
>>> + ? ? ? ?}
>>> + ? ?}
>>> +
>>> + ? ?ret = (ioctl(s->fd, CDROM_DRIVE_STATUS, CDSL_CURRENT) == CDS_DISC_OK);
>>> +
>>> + ? ?if (!ret) {
>>> + ? ? ? ?close(s->fd);
>>> + ? ? ? ?s->fd = -1;
>>> + ? ?}
>>> + ? ?return ret;
>>> ?}
>>>
>>> ?static int cdrom_eject(BlockDriverState *bs, int eject_flag)
>>> --
>>> 1.7.4.1
>>>
>>>
>>>
>>
>> There is an issue with reopening host devices in QEMU when running
>> under libvirt. ?It appears that libvirt chowns image files (including
>> device nodes) so that the launched QEMU process can access them.
>>
>> Unfortunately after media change on host devices udev will reset the
>> ownership of the device node. ?This causes open(2) to fail with EACCES
>> since the QEMU process does not have the right uid/gid/groups and
>> libvirt is unaware that the file's ownership has changed.
>>
>> In order for media change to work with Linux host CD-ROM it is
>> necessary to reopen the file (otherwise the inode size will not
>> refresh, this is an issue with existing kernels).
>>
>> How can libvirt's security model be made to support this case? ?In
>> theory udev could be temporarily configured with libvirt permissions
>> for the CD-ROM device while passed through to the guest, but is that
>> feasible?
>
> How about something like this: Add an explicit reopen method to
> BlockDriver. Make a special block device for passed file descriptors.
> Pass descriptors in libvirt for CD-ROMs instead of the device paths.
> The reopen method for file descriptors should notify libvirt about
> need to pass a reopened descriptor and then block all accesses until a
> new descriptor is available. This should also solve your earlier
> problem.
I'm hoping libvirt's behavior can be made to just work rather than
adding new features to QEMU. But perhaps passing file descriptors is
useful for more than just reopening host devices. This would
basically be a privilege separation model where the QEMU process isn't
able to open files itself but can request libvirt to open them on its
behalf.
Stefan
From wency at cn.fujitsu.com Mon Apr 4 01:42:17 2011
From: wency at cn.fujitsu.com (Wen Congyang)
Date: Mon, 04 Apr 2011 09:42:17 +0800
Subject: [libvirt] [BUG] qemu quited unexpectedly will cause libvirtd
crashed
In-Reply-To: <4D94CDCA.50801@redhat.com>
References: <4D91B1BF.6050106@cn.fujitsu.com> <4D938B96.8090503@redhat.com>
<4D94224D.70905@cn.fujitsu.com> <4D94CDCA.50801@redhat.com>
Message-ID: <4D9921F9.6070506@cn.fujitsu.com>
At 04/01/2011 02:54 AM, Eric Blake Write:
> On 03/31/2011 12:42 AM, Wen Congyang wrote:
>>>> So I try to use gdb and add sleep() to trigger this bug. I have posted two patches
>>>> to fix 2 bugs. But there is still another bug, and I have no good way to fix it.
>>>
>>>> Steps to reproduce this bug:
>>>> 1. use gdb to attach libvirtd, and set a breakpoint in the function
>>>> qemuConnectMonitor()
>>>> 2. start a vm
>>>> 3. let the libvirtd to run until qemuMonitorSetCapabilities() returns.
>>>> 4. kill the qemu process
>>>> 5. step into qemuDomainObjExitMonitorWithDriver(), and set debug to 1
>>>>
>>>> Now, qemuDomainObjExitMonitorWithDriver() will sleep 100s to make sure
>>>> qemuProcessHandleMonitorEOF() is done before qemuProcessHandleMonitorEOF()
>>>> returns.
>>>>
>>>> priv->mon will be null after qemuDomainObjExitMonitorWithDriver() returns.
>>>> So we must not use it. Unfortunately we still use it, and it will cause
>>>> libvirtd crashed.
>>>
>>> Sounds like qemuConnectMonitor needs an extra reference around priv->mon
>>> for the duration of the connect attempt, so that
>>> qemuProcessHandleMonitorEOF will not free the monitor.
>>
>> No, qemuConnectMonitor() calls qemuDomainObjEnterMonitorWithDriver() to hold
>> an extra reference around priv->mon, and release it in qemuDomainObjExitMonitorWithDriver().
>> But qemuDomainObjExitMonitorWithDriver() does not tell the caller whether
>> priv->mon can be used.
>>
>> If we will call qemuDomainObjEnterMonitorWithDriver()/qemuDomainObjEnterMonitor(),
>> I think we must check whether the domain is active. If we call them more than once,
>> we must check it every time. And we should not do other things between checking whether
>> the domain is active and calling them(If we do as this, the code can be maintained easily)
>
> I think I hit on the same problem earlier, of a guest modifying vm state
> on assumption that a successful monitor command even if the vm went down
> in the window after the monitor command completed but before lock was
> regained:
>
> https://www.redhat.com/archives/libvir-list/2011-March/msg00636.html
>
>>
>> But some codes does not respect this rule.
>>
>> Here is the list of the functions that may have the similar problem:
>> 1. qemu_migration.c
>> doNativeMigrate()
>> qemuMigrationToFile()
>
> My current thoughts are that maybe qemuDomainObjExitMonitor should be
> made to return the value of vm active after regaining lock, and marked
> ATTRIBUTE_RETURN_CHECK, to force all other callers to detect the case of
> a monitor command completing successfully but then the VM disappearing
> in the window between command completion and regaining the vm lock.
We can make qemuDomainObjExitMonitor() to return a value of vm active after regaining
lock, and mark it ATTRIBUTE_RETURN_CHECK. The compiler can check the problem.
But if we do something like this:
{
...
qemuDomainObjBeginJob();
qemuDomainObjEnterMonitor();
...
}
Libvirtd still may crash as vm is inactive when qemuDomainObjBeginJob() returns and
vm->priv->mon is NULL.
function a()
{
...
qemuDomainObjEnterMonitor();
/* invoke monitor command */
qemuDomainObjExitMonitor();
...
}
function b()
{
...
ignore_value(a());
...
qemuDomainObjEnterMonitor();
...
}
If invoking monitor command failed is not a fatal problem, and we ignore the return value
of function a(). libvirtd may crash if a() failed.
The complier can not detect the above problems.
If we always check whether vm is active before calling qemuDomainObjEnterMonitor(), we can
avoid this problem.
From usui at mxm.nes.nec.co.jp Mon Apr 4 01:05:29 2011
From: usui at mxm.nes.nec.co.jp (Minoru Usui)
Date: Mon, 4 Apr 2011 10:05:29 +0900
Subject: [libvirt] [PATCH 1/6] virNodeGetCpuTime: Expose new API
In-Reply-To: <4D95FB08.20802@redhat.com>
References: <20110401103833.8b66b57e.usui@mxm.nes.nec.co.jp>
<20110401105548.a78607f7.usui@mxm.nes.nec.co.jp>
<4D95FB08.20802@redhat.com>
Message-ID: <20110404100529.510af367.usui@mxm.nes.nec.co.jp>
Hi, Eric
On Fri, 01 Apr 2011 10:19:20 -0600
Eric Blake wrote:
> On 03/31/2011 07:55 PM, Minoru Usui wrote:
> > virNodeGetCpuTime: Expose new API
> >
> > include/libvirt/libvirt.h.in | 26 ++++++++++++++++++++++++++
> > src/libvirt_public.syms | 1 +
> > 2 files changed, 27 insertions(+), 0 deletions(-)
>
> >
> > +/**
> > + * virNodeCpuTime:
> > + *
> > + * a virNodeCpuTime is a structure filled by virNodeGetCpuTime() and providing
> > + * the information for the cpu time of Node.
> > + */
> > +
> > +typedef struct _virNodeCpuTime virNodeCpuTime;
> > +
> > +struct _virNodeCpuTime {
> > + unsigned long long user;
> > + unsigned long long system;
> > + unsigned long long idle;
> > + unsigned long long iowait;
> > +};
>
> Can we portably get all of this information on Windows? If not, how do
> you express which values we don't know how to obtain?
>
> > @@ -593,6 +616,9 @@ int virNodeGetInfo (virConnectPtr conn,
> > virNodeInfoPtr info);
> > char * virConnectGetCapabilities (virConnectPtr conn);
> >
> > +int virNodeGetCpuTime (virConnectPtr conn,
> > + virNodeCpuTimePtr cpu_time);
> > +
>
> Rather than locking ourselves into yet another inflexible API (no flags
> parameter and a hard-coded struct means no way to extend this if we ever
> come up with some new stat to query), should we instead be following the
> lead of getMemoryParameters which takes a typed-name/value array to pass
> an arbitrary number of parameters, which allows extension without a new API?
OK.
I'll change its user I/F like virDomainGetMemoryParameters(),
if it doesn't return absolute CPU time values.
> > +++ b/src/libvirt_public.syms
> > @@ -434,6 +434,7 @@ LIBVIRT_0.9.0 {
> > virEventRunDefaultImpl;
> > virStorageVolDownload;
> > virStorageVolUpload;
> > + virNodeGetCpuTime;
> > } LIBVIRT_0.8.8;
>
> While I think that something along the lines of this API is appropriate
> for libvirt (indeed, knowing a host's CPU utilization can indeed be a
> factor for upper-level management software in deciding whether to
> migrate another domain on or off of the machine), it's too late to put
> it into 0.9.0. We'd be setting bad precedent by accepting this after
> the first release candidate did a feature freeze, so you'd need to
> adjust this to 0.9.1.
OK.
I'll change it.
>
> --
> Eric Blake eblake at redhat.com +1-801-349-2682
> Libvirt virtualization library http://libvirt.org
>
--
Minoru Usui
From usui at mxm.nes.nec.co.jp Mon Apr 4 02:03:10 2011
From: usui at mxm.nes.nec.co.jp (Minoru Usui)
Date: Mon, 4 Apr 2011 11:03:10 +0900
Subject: [libvirt] [PATCH 1/6] virNodeGetCpuTime: Expose new API
In-Reply-To:
References: <20110401103833.8b66b57e.usui@mxm.nes.nec.co.jp>
<20110401105548.a78607f7.usui@mxm.nes.nec.co.jp>
<4D95FB08.20802@redhat.com>
Message-ID: <20110404110310.e85d09ba.usui@mxm.nes.nec.co.jp>
Hi, Matthias.
On Fri, 1 Apr 2011 20:22:17 +0200
Matthias Bolte wrote:
> 2011/4/1 Eric Blake :
> > On 03/31/2011 07:55 PM, Minoru Usui wrote:
> >> virNodeGetCpuTime: Expose new API
> >>
> >> ?include/libvirt/libvirt.h.in | ? 26 ++++++++++++++++++++++++++
> >> ?src/libvirt_public.syms ? ? ?| ? ?1 +
> >> ?2 files changed, 27 insertions(+), 0 deletions(-)
> >
> >>
> >> +/**
> >> + * virNodeCpuTime:
> >> + *
> >> + * a virNodeCpuTime is a structure filled by virNodeGetCpuTime() and providing
> >> + * the information for the cpu time of Node.
> >> + */
> >> +
> >> +typedef struct _virNodeCpuTime virNodeCpuTime;
> >> +
> >> +struct _virNodeCpuTime {
> >> + ? ?unsigned long long user;
> >> + ? ?unsigned long long system;
> >> + ? ?unsigned long long idle;
> >> + ? ?unsigned long long iowait;
> >> +};
> >
> > Can we portably get all of this information on Windows? ?If not, how do
> > you express which values we don't know how to obtain?
> >
>
> In the context of ESX I vote against this absolute CPU time values.
> ESX provides this values relative to a 20 second timeslots with 1 hour
> of history. This makes it nearly impossible to obtain the absolute CPU
> time. The same problem already exists for the domain's virtual CPU
> time.
>
> When you look at virt-top's usage of the domain's virtual CPU time,
> you see that it actually doesn't really care about the absolute value,
> but deduces the CPU utilization from it. I suggest that we find a
> different representation for this information that is not by
> definition impossible to implement for ESX.
>
> Matthias
I didn't know ESX couldn't return absolute CPU time value.
Thank you for your comment.
We really want to get CPU utilization information of the node, not
absolute CPU time values.
But linux doesn't provide CPU utilization directly,
so my patch returns absolute CPU time values,
and CPU utilization is calculated by client which uses new API.
To return CPU utilization by new API, I think there are two issues of implementing on linux.
a) How much interval does calculate CPU utilization?
To calculate CPU utilization on linux, we need to get absolute CPU time value of the node
from /proc/stat two times.
How much interval properly? 1sec? 1min? or others?
b) Can new API wait its interval?
If we select simply implementation, new API waits its interval.
But API user don't want to wait every API calls, if its interval is long.
So I think libvirtd will be calculating CPU utilization in background every interval.
Is this approach OK?
--
Minoru Usui
From veillard at redhat.com Mon Apr 4 03:02:37 2011
From: veillard at redhat.com (Daniel Veillard)
Date: Mon, 4 Apr 2011 11:02:37 +0800
Subject: [libvirt] [PATCH] vmx: Use case-insensitive compare functions
for all content
In-Reply-To: <20110403121914.GA22826@sbox>
References: <20110403121914.GA22826@sbox>
Message-ID: <20110404030237.GP24385@redhat.com>
On Sun, Apr 03, 2011 at 02:19:14PM +0200, Matthias Bolte wrote:
> ---
> src/vmx/vmx.c | 10 +++++-----
> 1 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
> index 9f4d5fb..9a482ef 100644
> --- a/src/vmx/vmx.c
> +++ b/src/vmx/vmx.c
> @@ -730,7 +730,7 @@ virVMXGetConfigLong(virConfPtr conf, const char *name, long long *number,
> }
> }
>
> - if (STREQ(value->str, "unlimited")) {
> + if (STRCASEEQ(value->str, "unlimited")) {
> *number = -1;
> } else if (virStrToLong_ll(value->str, NULL, 10, number) < 0) {
> VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
> @@ -1385,7 +1385,7 @@ virVMXParseConfig(virVMXContext *ctx, virCapsPtr caps, const char *vmx)
> goto cleanup;
> }
>
> - if (sched_cpu_affinity != NULL && STRNEQ(sched_cpu_affinity, "all")) {
> + if (sched_cpu_affinity != NULL && STRCASENEQ(sched_cpu_affinity, "all")) {
> const char *current = sched_cpu_affinity;
> int number, count = 0;
>
> @@ -2107,7 +2107,7 @@ virVMXParseDisk(virVMXContext *ctx, virCapsPtr caps, virConfPtr conf,
> goto cleanup;
> }
> } else if (virFileHasSuffix(fileName, ".iso") ||
> - STREQ(deviceType, "atapi-cdrom")) {
> + STRCASEEQ(deviceType, "atapi-cdrom")) {
> /*
> * This function was called in order to parse a harddisk device,
> * but .iso files and 'atapi-cdrom' devices are for CDROM devices
> @@ -2146,7 +2146,7 @@ virVMXParseDisk(virVMXContext *ctx, virCapsPtr caps, virConfPtr conf,
> * handle it.
> */
> goto ignore;
> - } else if (STREQ(deviceType, "atapi-cdrom")) {
> + } else if (STRCASEEQ(deviceType, "atapi-cdrom")) {
> (*def)->type = VIR_DOMAIN_DISK_TYPE_BLOCK;
> (*def)->src = fileName;
>
> @@ -2174,7 +2174,7 @@ virVMXParseDisk(virVMXContext *ctx, virCapsPtr caps, virConfPtr conf,
> if ((*def)->src == NULL) {
> goto cleanup;
> }
> - } else if (fileType != NULL && STREQ(fileType, "device")) {
> + } else if (fileType != NULL && STRCASEEQ(fileType, "device")) {
> (*def)->type = VIR_DOMAIN_DISK_TYPE_BLOCK;
> (*def)->src = fileName;
Sounds fine to me but would you categorize this as bug fix (for 0.9.0)
or rather an improvement and wait. I guess it depends how you ended up
crossing this, and I can't guess it :-)
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel at veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
From veillard at redhat.com Mon Apr 4 03:05:41 2011
From: veillard at redhat.com (Daniel Veillard)
Date: Mon, 4 Apr 2011 11:05:41 +0800
Subject: [libvirt] [PATCH] vmx: Support persistent CPU shares
In-Reply-To: <20110403124355.GA22943@sbox>
References: <20110403124355.GA22943@sbox>
Message-ID: <20110404030541.GQ24385@redhat.com>
On Sun, Apr 03, 2011 at 02:43:55PM +0200, Matthias Bolte wrote:
> ---
> src/vmx/vmx.c | 43 ++++++++++++++++++++++
> tests/vmx2xmldata/vmx2xml-case-insensitive-1.vmx | 2 +-
> tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml | 3 ++
> tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml | 3 ++
> tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.vmx | 2 +-
> tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.xml | 3 ++
> tests/vmx2xmldata/vmx2xml-esx-in-the-wild-4.xml | 3 ++
> tests/vmx2xmldata/vmx2xml-esx-in-the-wild-5.xml | 3 ++
> tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.vmx | 1 +
> tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.xml | 3 ++
> tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.vmx | 1 +
> tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.xml | 3 ++
> tests/xml2vmxdata/xml2vmx-esx-in-the-wild-5.vmx | 1 +
> tests/xml2vmxdata/xml2vmx-esx-in-the-wild-5.xml | 3 ++
> 14 files changed, 72 insertions(+), 2 deletions(-)
>
> diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
> index 9a482ef..b0d3218 100644
> --- a/src/vmx/vmx.c
> +++ b/src/vmx/vmx.c
> @@ -55,6 +55,8 @@ def->mem.cur_balloon = <=> sched.mem.max = " def->mem.min_guarantee = <=> sched.mem.minsize = "" # defaults to 0
> def->maxvcpus = <=> numvcpus = "" # must be 1 or a multiple of 2, defaults to 1
> def->cpumask = <=> sched.cpu.affinity = ""
> +def->cputune.shares = <=> sched.cpu.shares = "" # with handling for special values
> + # "high", "normal", "low"
>
>
>
> @@ -1200,6 +1202,7 @@ virVMXParseConfig(virVMXContext *ctx, virCapsPtr caps, const char *vmx)
> long long sched_mem_minsize = 0;
> long long numvcpus = 0;
> char *sched_cpu_affinity = NULL;
> + char *sched_cpu_shares = NULL;
> char *guestOS = NULL;
> bool smbios_reflecthost = false;
> int controller;
> @@ -1449,6 +1452,30 @@ virVMXParseConfig(virVMXContext *ctx, virCapsPtr caps, const char *vmx)
> }
> }
>
> + /* vmx:sched.cpu.shares -> def:cputune.shares */
> + if (virVMXGetConfigString(conf, "sched.cpu.shares", &sched_cpu_shares,
> + true) < 0) {
> + goto cleanup;
> + }
> +
> + if (sched_cpu_shares != NULL) {
> + /* See http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.SharesInfo.Level.html */
> + if (STRCASEEQ(sched_cpu_shares, "low")) {
> + def->cputune.shares = def->vcpus * 500;
> + } else if (STRCASEEQ(sched_cpu_shares, "normal")) {
> + def->cputune.shares = def->vcpus * 1000;
> + } else if (STRCASEEQ(sched_cpu_shares, "high")) {
> + def->cputune.shares = def->vcpus * 2000;
> + } else if (virStrToLong_ul(sched_cpu_shares, NULL, 10,
> + &def->cputune.shares) < 0) {
> + VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
> + _("Expecting VMX entry 'sched.cpu.shares' to be an "
> + "unsigned integer or 'low', 'normal' or 'high' but "
> + "found '%s'"), sched_cpu_shares);
> + goto cleanup;
> + }
> + }
> +
> /* def:lifecycle */
> def->onReboot = VIR_DOMAIN_LIFECYCLE_RESTART;
> def->onPoweroff = VIR_DOMAIN_LIFECYCLE_DESTROY;
> @@ -1715,6 +1742,7 @@ virVMXParseConfig(virVMXContext *ctx, virCapsPtr caps, const char *vmx)
> virConfFree(conf);
> VIR_FREE(encoding);
> VIR_FREE(sched_cpu_affinity);
> + VIR_FREE(sched_cpu_shares);
> VIR_FREE(guestOS);
>
> return def;
> @@ -2998,6 +3026,21 @@ virVMXFormatConfig(virVMXContext *ctx, virCapsPtr caps, virDomainDefPtr def,
> virBufferAddLit(&buffer, "\"\n");
> }
>
> + /* def:cputune.shares -> vmx:sched.cpu.shares */
> + if (def->cputune.shares > 0) {
> + /* See http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.SharesInfo.Level.html */
> + if (def->cputune.shares == def->vcpus * 500) {
> + virBufferAddLit(&buffer, "sched.cpu.shares = \"low\"\n");
> + } else if (def->cputune.shares == def->vcpus * 1000) {
> + virBufferAddLit(&buffer, "sched.cpu.shares = \"normal\"\n");
> + } else if (def->cputune.shares == def->vcpus * 2000) {
> + virBufferAddLit(&buffer, "sched.cpu.shares = \"high\"\n");
> + } else {
> + virBufferVSprintf(&buffer, "sched.cpu.shares = \"%lu\"\n",
> + def->cputune.shares);
> + }
> + }
> +
> /* def:graphics */
> for (i = 0; i < def->ngraphics; ++i) {
> switch (def->graphics[i]->type) {
> diff --git a/tests/vmx2xmldata/vmx2xml-case-insensitive-1.vmx b/tests/vmx2xmldata/vmx2xml-case-insensitive-1.vmx
> index bd36cf8..8641c5c 100644
> --- a/tests/vmx2xmldata/vmx2xml-case-insensitive-1.vmx
> +++ b/tests/vmx2xmldata/vmx2xml-case-insensitive-1.vmx
> @@ -35,7 +35,7 @@ UUID.BIOS = "50 11 5E 16 9B DC 49 D7-F1 71 53 C4 D7 F9 17 10"
> SNAPSHOT.ACTION = "KEEP"
> SCHED.CPU.MIN = "0"
> SCHED.CPU.UNITS = "MHZ"
> -SCHED.CPU.SHARES = "NORMAL"
> +SCHED.CPU.SHARES = "4223"
> SCHED.MEM.MINSIZE = "0"
> SCHED.MEM.SHARES = "NORMAL"
> TOOLSCRIPTS.AFTERPOWERON = "TRUE"
> diff --git a/tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml b/tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml
> index 7a5ff5b..ef6edd8 100644
> --- a/tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml
> +++ b/tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml
> @@ -4,6 +4,9 @@
> 1048576
> 1048576
> 1
> +
> + 4223
> +
>
> hvm
>
> diff --git a/tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml b/tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml
> index 18d6461..02771b9 100644
> --- a/tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml
> +++ b/tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml
> @@ -4,6 +4,9 @@
> 1048576
> 1048576
> 1
> +
> + 1000
> +
>
> hvm
>
> diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.vmx b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.vmx
> index 4392062..78741ae 100644
> --- a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.vmx
> +++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.vmx
> @@ -36,7 +36,7 @@ uuid.bios = "50 11 5e 16 9b dc 49 d7-f1 71 53 c4 d7 f9 17 10"
> snapshot.action = "keep"
> sched.cpu.min = "0"
> sched.cpu.units = "mhz"
> -sched.cpu.shares = "normal"
> +sched.cpu.shares = "low"
> sched.mem.minsize = "0"
> sched.mem.shares = "normal"
> toolScripts.afterPowerOn = "true"
> diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.xml b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.xml
> index 5e67e74..e8f9307 100644
> --- a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.xml
> +++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.xml
> @@ -4,6 +4,9 @@
> 1048576
> 1048576
> 1
> +
> + 500
> +
>
> hvm
>
> diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-4.xml b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-4.xml
> index 419df51..2824d66 100644
> --- a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-4.xml
> +++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-4.xml
> @@ -4,6 +4,9 @@
> 524288
> 524288
> 1
> +
> + 1000
> +
>
> hvm
>
> diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-5.xml b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-5.xml
> index 0040163..6f0a9d1 100644
> --- a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-5.xml
> +++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-5.xml
> @@ -8,6 +8,9 @@
> 262144
>
> 2
> +
> + 2000
> +
>
> hvm
>
> diff --git a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.vmx b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.vmx
> index e72ca80..9059197 100644
> --- a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.vmx
> +++ b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.vmx
> @@ -6,6 +6,7 @@ uuid.bios = "50 11 5e 16 9b dc 49 d7-f1 71 53 c4 d7 f9 17 10"
> displayName = "Fedora11"
> memsize = "1024"
> numvcpus = "1"
> +sched.cpu.shares = "low"
> scsi0.present = "true"
> scsi0.virtualDev = "lsilogic"
> scsi0:0.present = "true"
> diff --git a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.xml b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.xml
> index 3f4ff88..ea59778 100644
> --- a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.xml
> +++ b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.xml
> @@ -4,6 +4,9 @@
> 1048576
> 1048576
> 1
> +
> + 500
> +
>
> hvm
>
> diff --git a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.vmx b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.vmx
> index 627fcfb..504997f 100644
> --- a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.vmx
> +++ b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.vmx
> @@ -6,6 +6,7 @@ uuid.bios = "56 4d 9b ef ac d9 b4 e0-c8 f0 ae a8 b9 10 35 15"
> displayName = "virtMonServ1"
> memsize = "512"
> numvcpus = "1"
> +sched.cpu.shares = "normal"
> scsi0.present = "true"
> scsi0.virtualDev = "lsilogic"
> scsi0:0.present = "true"
> diff --git a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.xml b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.xml
> index 078753a..443aacd 100644
> --- a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.xml
> +++ b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.xml
> @@ -4,6 +4,9 @@
> 524288
> 524288
> 1
> +
> + 1000
> +
>
> hvm
>
> diff --git a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-5.vmx b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-5.vmx
> index cc2485f..2e3b856 100644
> --- a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-5.vmx
> +++ b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-5.vmx
> @@ -8,6 +8,7 @@ annotation = "Centos 5.5 64bit Server"
> memsize = "2048"
> sched.mem.minsize = "256"
> numvcpus = "2"
> +sched.cpu.shares = "normal"
> scsi0.present = "true"
> scsi0.virtualDev = "lsilogic"
> scsi0:0.present = "true"
> diff --git a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-5.xml b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-5.xml
> index d55bf6b..f28c15e 100644
> --- a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-5.xml
> +++ b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-5.xml
> @@ -8,6 +8,9 @@
> 262144
>
> 2
> +
> + 2000
> +
>
> hvm
>
ACK, while nice, it may be a bit late for 0.9.0, okay to wait for the
next cycle ? We already have this for xen and qemu, seeing it for ESX
confirms the design is fine, which is the most important from my point
of vue :-)
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel at veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
From veillard at redhat.com Mon Apr 4 03:11:23 2011
From: veillard at redhat.com (Daniel Veillard)
Date: Mon, 4 Apr 2011 11:11:23 +0800
Subject: [libvirt] [RFC PATCH] build: detect doc build errors
In-Reply-To: <1301695610-4003-1-git-send-email-eblake@redhat.com>
References: <1301695610-4003-1-git-send-email-eblake@redhat.com>
Message-ID: <20110404031123.GR24385@redhat.com>
On Fri, Apr 01, 2011 at 04:06:50PM -0600, Eric Blake wrote:
> I'm still stumped by xsltproc complaining about not being a
> valid XML entity, hence the (hackish) exemption in docs/Makefile.am
> that adds --html for a couple of .html.in files. But for the
> remaining files, this does make input validation stricter, and caught
> several bugs.
The only solution would be to add a DTD to the html.in which use
any entity beyond the 5 ones hardcoded in the parser (lt, gt, amp,
quot and apos.
> Hence, this is an RFC (either we live with my hack that caught
> all the issues in the prior patch, or someone with more xsltproc
> knowledge than me will step in and teach it how to resolve html
> entities while processing the documents as xml instead of html).
We would need to add
to all the .html.in for consistency, since we now expect them to be
well formed XML and possibly using html entities.
> * docs/Makefile.am (maintainer-clean-local): Remove generated docs
> in VPATH build.
> (%.html.tmp): Don't use looser --html; our input should be strict
> xhtml. HACK - use --html when entities like are involved.
> (html/index.html): Exit on formatting problems.
> (rebuild): Run full doc build on request.
> ---
> docs/Makefile.am | 24 ++++++++++++++----------
> 1 files changed, 14 insertions(+), 10 deletions(-)
>
> diff --git a/docs/Makefile.am b/docs/Makefile.am
> index db4bc59..2d1afe4 100644
> --- a/docs/Makefile.am
> +++ b/docs/Makefile.am
> @@ -123,7 +123,7 @@ internals/%.html.tmp: internals/%.html.in subsite.xsl page.xsl sitemap.html.in
> echo "Generating $@"; \
> $(MKDIR_P) "$(builddir)/internals"; \
> name=`echo $@ | sed -e 's/.tmp//'`; \
> - $(XSLTPROC) --stringparam pagename $$name --nonet --html \
> + $(XSLTPROC) --stringparam pagename $$name --nonet \
> $(top_srcdir)/docs/subsite.xsl $< > $@ \
> || { rm $@ && exit 1; }; fi
>
> @@ -131,7 +131,8 @@ internals/%.html.tmp: internals/%.html.in subsite.xsl page.xsl sitemap.html.in
> @if [ -x $(XSLTPROC) ] ; then \
> echo "Generating $@"; \
> name=`echo $@ | sed -e 's/.tmp//'`; \
> - $(XSLTPROC) --stringparam pagename $$name --nonet --html \
> + $(XSLTPROC) --stringparam pagename $$name --nonet \
> + $$(grep -qE '&(nbsp|uuml|mdash);' $< && printf %s --html) \
> $(top_srcdir)/docs/site.xsl $< > $@ \
> || { rm $@ && exit 1; }; fi
>
> @@ -147,21 +148,22 @@ internals/%.html.tmp: internals/%.html.in subsite.xsl page.xsl sitemap.html.in
>
>
> html/index.html: libvirt-api.xml newapi.xsl page.xsl sitemap.html.in
> - - at if [ -x $(XSLTPROC) ] ; then \
> + @if [ -x $(XSLTPROC) ] ; then \
> echo "Rebuilding the HTML pages from the XML API" ; \
> $(XSLTPROC) --nonet -o $(srcdir)/ \
> $(srcdir)/newapi.xsl $(srcdir)/libvirt-api.xml ; fi
> - - at if test -x $(XMLLINT) && test -x $(XMLCATALOG) ; then \
> - if $(XMLCATALOG) '$(XML_CATALOG_FILE)' "-//W3C//DTD XHTML 1.0 Strict//EN" \
> - > /dev/null ; then \
> + @if test -x $(XMLLINT) && test -x $(XMLCATALOG) ; then \
> + if $(XMLCATALOG) '$(XML_CATALOG_FILE)' \
> + "-//W3C//DTD XHTML 1.0 Strict//EN" > /dev/null ; then \
> echo "Validating the resulting XHTML pages" ; \
> SGML_CATALOG_FILES='$(XML_CATALOG_FILE)' \
> - $(XMLLINT) --catalogs --nonet --valid --noout $(srcdir)/html/*.html ; \
> + $(XMLLINT) --catalogs --nonet --valid --noout $(srcdir)/html/*.html \
> + || { rm $(srcdir)/$@ && exit 1; }; \
> else echo "missing XHTML1 DTD" ; fi ; fi
>
> $(addprefix $(srcdir)/,$(devhelphtml)): $(srcdir)/libvirt-api.xml $(devhelpxsl)
> - at echo Rebuilding devhelp files
> - - at if [ -x $(XSLTPROC) ] ; then \
> + @if [ -x $(XSLTPROC) ] ; then \
> $(XSLTPROC) --nonet -o $(srcdir)/devhelp/ \
> $(top_srcdir)/docs/devhelp/devhelp.xsl $(srcdir)/libvirt-api.xml ; fi
>
> @@ -183,9 +185,11 @@ clean-local:
> rm -f *~ *.bak *.hierarchy *.signals *-unused.txt *.html
>
> maintainer-clean-local: clean-local
> - rm -rf $(srcdir)/libvirt-api.xml $(srcdir)/libvirt-refs.xml todo.html.in
> + rm -rf $(srcdir)/libvirt-api.xml $(srcdir)/libvirt-refs.xml \
> + todo.html.in $(srcdir)/*.html $(srcdir)/devhelp/*.html \
> + $(srcdir)/html/*.html $(srcdir)/internals/*.html
>
> -rebuild: api all
> +rebuild: maintainer-clean-local api all
>
> install-data-local:
> $(mkinstalldirs) $(DESTDIR)$(HTML_DIR)
> --
> 1.7.4
I think I will check this in a few hours while preparing the release,
depending on the size of the resulting diff, I may put this in, as is,
add the DTD and go full XML or keep as-is ...
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel at veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
From hahn at univention.de Mon Apr 4 06:08:27 2011
From: hahn at univention.de (Philipp Hahn)
Date: Mon, 4 Apr 2011 08:08:27 +0200
Subject: [libvirt] [BUG] qemu: snapshots no longer shown after migration^2
Message-ID: <201104040808.32278.hahn@univention.de>
Hello,
when a domain is migrated to another host and than back again, snapshots of
this domain are no longer shown.
I think that is because qemuDomainSnapshotLoad() is only called once from
qemudStartup() during startup, but not after migration (or re-definition of a
previously deleted domain, e.g. offline-migration)
No patch yet, but this is tracked at our German bugzilla at
Sincerely
Philipp Hahn
--
Philipp Hahn Open Source Software Engineer hahn at univention.de
Univention GmbH Linux for Your Business fon: +49 421 22 232- 0
Mary-Somerville-Str.1 D-28359 Bremen fax: +49 421 22 232-99
http://www.univention.de/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL:
From matthias.bolte at googlemail.com Mon Apr 4 06:28:24 2011
From: matthias.bolte at googlemail.com (Matthias Bolte)
Date: Mon, 4 Apr 2011 08:28:24 +0200
Subject: [libvirt] [PATCH] vmx: Support persistent CPU shares
In-Reply-To: <20110404030541.GQ24385@redhat.com>
References: <20110403124355.GA22943@sbox> <20110404030541.GQ24385@redhat.com>
Message-ID:
2011/4/4 Daniel Veillard :
> On Sun, Apr 03, 2011 at 02:43:55PM +0200, Matthias Bolte wrote:
>> ---
>> ?src/vmx/vmx.c ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?| ? 43 ++++++++++++++++++++++
>> ?tests/vmx2xmldata/vmx2xml-case-insensitive-1.vmx | ? ?2 +-
>> ?tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml | ? ?3 ++
>> ?tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml | ? ?3 ++
>> ?tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.vmx ?| ? ?2 +-
>> ?tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.xml ?| ? ?3 ++
>> ?tests/vmx2xmldata/vmx2xml-esx-in-the-wild-4.xml ?| ? ?3 ++
>> ?tests/vmx2xmldata/vmx2xml-esx-in-the-wild-5.xml ?| ? ?3 ++
>> ?tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.vmx ?| ? ?1 +
>> ?tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.xml ?| ? ?3 ++
>> ?tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.vmx ?| ? ?1 +
>> ?tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.xml ?| ? ?3 ++
>> ?tests/xml2vmxdata/xml2vmx-esx-in-the-wild-5.vmx ?| ? ?1 +
>> ?tests/xml2vmxdata/xml2vmx-esx-in-the-wild-5.xml ?| ? ?3 ++
>> ?14 files changed, 72 insertions(+), 2 deletions(-)
>>
>
> ?ACK, while nice, it may be a bit late for 0.9.0, okay to wait for the
> next cycle ? We already have this for xen and qemu, seeing it for ESX
> confirms the design is fine, which is the most important from my point
> of vue :-)
>
> Daniel
>
Sure, this can wait until 0.9.1. On the ESX side the shares value is
persistent anyway. This patch just exposes it as persistent in libvirt
too.
Matthias
From izumi.taku at jp.fujitsu.com Mon Apr 4 07:24:34 2011
From: izumi.taku at jp.fujitsu.com (Taku Izumi)
Date: Mon, 04 Apr 2011 16:24:34 +0900
Subject: [libvirt] [PATCH v2 0/4] configure inactive domains' maximum
memory size
In-Reply-To: <4D95FDEE.8060609@redhat.com>
References: <4D940EEE.2090603@jp.fujitsu.com> <4D95FDEE.8060609@redhat.com>
Message-ID: <4D997232.2070009@jp.fujitsu.com>
Hi Eric,
(2011/04/02 1:31), Eric Blake wrote:
> On 03/30/2011 11:19 PM, Taku Izumi wrote:
>> Hi all,
>>
>> This patchset enables us to configure inactive domain's maximum memory
>> size. I redesigned according to Daniel-san's commnet.
>
>> The following patchset is the prerequisite of these.
>> => http://www.redhat.com/archives/libvir-list/2011-March/msg01057.html
>
> My sincere apologies at the delay on these series. I've been so focused
> on locking bugs and libvirtd crashers that I haven't had a chance to
> properly review any of the persistent settings patches in time for
> inclusion in 0.9.0. My justification is that you can always achieve
> persistent settings (albeit with undue pain) by raw XML editing, so this
> is just an enhancement request rather than a bug fix. However, now that
> we've missed the feature freeze deadline for 0.9.0, you have my promise
> that I will be reviewing this next week for inclusion in 0.9.1.
>
That's OK, I don't mind.
Please review this after releasing 0.9.0.
Best regards,
Taku Izumi
From izumi.taku at jp.fujitsu.com Mon Apr 4 07:26:08 2011
From: izumi.taku at jp.fujitsu.com (Taku Izumi)
Date: Mon, 04 Apr 2011 16:26:08 +0900
Subject: [libvirt] [PATCH 1/4] vcpupin: inroduce a new libvir
API (virDomainPinVcpuFlags)
In-Reply-To: <4D9601B4.60206@redhat.com>
References: <4D94124A.1090808@jp.fujitsu.com> <4D94133A.30806@jp.fujitsu.com>
<4D9601B4.60206@redhat.com>
Message-ID: <4D997290.8070708@jp.fujitsu.com>
(2011/04/02 1:47), Eric Blake wrote:
> On 03/30/2011 11:38 PM, Taku Izumi wrote:
>>
>> This patch introduces a new libvirt API (virDomainPinVcpuFlags)
>>
>> Signed-off-by: Taku Izumi
>
>> /**
>> + * virDomainPinVcpuFlags:
>> + * @domain: pointer to domain object, or NULL for Domain0
>> + * @vcpu: virtual CPU number
>> + * @cpumap: pointer to a bit map of real CPUs (in 8-bit bytes) (IN)
>> + * Each bit set to 1 means that correspoinding CPU is usable.
>
> s/correspoinding/corresponding/
>
>> + * Bytes are stored in little-endian order: CPU0-7, 8-15...
>> + * In each byte, lowest CPU number is least significant bit.
>> + * @maplen: number of bytes in cpumap, from 1 up to size of CPU map in
>> + * underlying virtualization system (Xen...).
>> + * If maplen< size, missing bytes are set to zero.
>> + * If maplen< size, failure code is returned.
>
> s/>/
>
>> + * @flags: an OR'ed set of virDomainVcpuFlags
>
> Is VIR_DOMAIN_VCPU_MAXIMUM really applicable here? The docs should
> probably mention that it is a subset of virDomainVcpuFlags.
>
>> + *
>> + * Dynamically change the real CPUs which can be allocated to a virtual CPU.
>> + * This function requires privileged access to the hypervisor.
>> + *
>> + * @flags must include VIR_DOMAIN_VCPU_LIVE to affect a running domain
>> + * (which may fail if domain is not active), or VIR_DOMAIN_MEM_CONFIG to
>
> s/VIR_DOMAIN_MEM_CONFIG/VIR_DOMAIN_VCPU_CONFIG/
>
>> + * affect the next boot via the XML description of the domain.
>> + * Both flags may be set.
>> + *
>> + * Returns 0 in case of success, -1 in case of failure.
>> + *
>> + */
>> +int
>> +virDomainPinVcpuFlags(virDomainPtr domain, unsigned int vcpu,
>> + unsigned char *cpumap, int maplen, unsigned int flags)
>> +{
>> Index: libvirt/src/libvirt_public.syms
>> ===================================================================
>> --- libvirt.orig/src/libvirt_public.syms
>> +++ libvirt/src/libvirt_public.syms
>> @@ -434,6 +434,7 @@ LIBVIRT_0.9.0 {
>> virEventRunDefaultImpl;
>> virStorageVolDownload;
>> virStorageVolUpload;
>> + virDomainPinVcpuFlags;
>> } LIBVIRT_0.8.8;
>
> We've missed the 0.9.0 feature freeze, can you adjust this patch series
> to be for 0.9.1?
>
Thank you for reviewing.
I'll rebase this patch set after releasing libvirt 0.9.0.
Best regards,
Taku Izumi
From minovotn at redhat.com Mon Apr 4 08:32:16 2011
From: minovotn at redhat.com (Michal Novotny)
Date: Mon, 04 Apr 2011 10:32:16 +0200
Subject: [libvirt] [libvirt-php] Fixed set_error when argument is NULL
In-Reply-To: <1301714430-9304-1-git-send-email-liyong@skybility.com>
References: <1301714430-9304-1-git-send-email-liyong@skybility.com>
Message-ID: <4D998210.6070900@redhat.com>
On 04/02/2011 05:20 AM, Lyre wrote:
> Avoid freeing a NULL pointer
> ---
> src/libvirt-php.c | 8 ++++++--
> 1 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/src/libvirt-php.c b/src/libvirt-php.c
> index 6a76f45..66b1de9 100644
> --- a/src/libvirt-php.c
> +++ b/src/libvirt-php.c
> @@ -237,12 +237,16 @@ PHP_MINFO_FUNCTION(libvirt)
> */
> void set_error(char *msg TSRMLS_DC)
> {
> - if (msg == NULL) {
> + if (LIBVIRT_G (last_error) != NULL)
> + {
> efree(LIBVIRT_G (last_error));
> + }
> +
> + if (msg == NULL) {
> + LIBVIRT_G (last_error) = NULL;
> return;
> }
> php_error_docref(NULL TSRMLS_CC, E_WARNING,"%s",msg);
> - if (LIBVIRT_G (last_error)!=NULL) efree(LIBVIRT_G (last_error));
> LIBVIRT_G (last_error)=estrndup(msg,strlen(msg));
> }
>
Good pick. Thanks! Pushed now.
Michal
--
Michal Novotny , RHCE
Virtualization Team (xen userspace), Red Hat
From mcastrol at gmail.com Mon Apr 4 09:58:25 2011
From: mcastrol at gmail.com (=?ISO-8859-1?Q?Marcela_Castro_Le=F3n?=)
Date: Mon, 4 Apr 2011 11:58:25 +0200
Subject: [libvirt] LIBVIRT migration
In-Reply-To:
References:
<20110401142611.GK29510@redhat.com>
Message-ID:
Hello
I'm having problem using migration. I'm working on ubuntu 10.4 and this
versions of libvirt and virsh:
virsh # version
Compiled against library: libvir 0.7.5
Using library: libvir 0.7.5
Using API: QEMU 0.7.5
Running hypervisor: QEMU 0.12.3
This is the error.
*virsh # migrate scompi1 qemu+ssh://rionegro/system
error: Unknown failure
*
This is the log on the destination, that show that there is no communication
problem, but it has a problem starting the guest on destination.
radic at rionegro:~$ sudo cat /var/log/libvirt/qemu/scompi1.log
[sudo] password for radic:
LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
QEMU_AUDIO_DRV=none /usr/bin/qemu-system-x86_64 -S -M pc-0.12 -enable-kvm -m
4096 -smp 4 -name scompi1 -uuid 355123af-b683-9fa6-ca31-10506c9ab9da
-chardev
socket,id=monitor,path=/var/lib/libvirt/qemu/scompi1.monitor,server,nowait
-monitor chardev:monitor -boot c -drive
file=/home/radic/mvdata/imagenes/scompi1.img,if=ide,index=0,boot=on,format=raw
-drive if=ide,media=cdrom,index=2,format=raw -net
nic,macaddr=52:54:00:05:d1:2a,vlan=0,model=virtio,name=virtio.0 -net
tap,fd=33,vlan=0,name=tap.0 -chardev pty,id=serial0 -serial chardev:serial0
-parallel none -usb -vnc 127.0.0.1:0 -vga cirrus -incoming tcp:0.0.0.0:49153
char device redirected to /dev/pts/1
LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
QEMU_AUDIO_DRV=none /usr/bin/qemu-system-x86_64 -S -M pc-0.12 -enable-kvm -m
4096 -smp 4 -name scompi1 -uuid 355123af-b683-9fa6-ca31-10506c9ab9da
-chardev
socket,id=monitor,path=/var/lib/libvirt/qemu/scompi1.monitor,server,nowait
-monitor chardev:monitor -boot c -drive
file=/home/radic/mvdata/imagenes/scompi1.img,if=ide,index=0,boot=on,format=raw
-drive if=ide,media=cdrom,index=2,format=raw -net
nic,macaddr=52:54:00:05:d1:2a,vlan=0,model=virtio,name=virtio.0 -net
tap,fd=33,vlan=0,name=tap.0 -chardev pty,id=serial0 -serial chardev:serial0
-parallel none -usb -vnc 127.0.0.1:0 -vga cirrus -incoming tcp:0.0.0.0:49154
char device redirected to /dev/pts/2
LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
QEMU_AUDIO_DRV=none /usr/bin/qemu-system-x86_64 -S -M pc-0.12 -enable-kvm -m
4096 -smp 4 -name scompi1 -uuid 355123af-b683-9fa6-ca31-10506c9ab9da
-chardev
socket,id=monitor,path=/var/lib/libvirt/qemu/scompi1.monitor,server,nowait
-monitor chardev:monitor -boot c -drive
file=/home/radic/mvdata/imagenes/scompi1.img,if=ide,index=0,boot=on,format=raw
-drive if=ide,media=cdrom,index=2,format=raw -net
nic,macaddr=52:54:00:05:d1:2a,vlan=0,model=virtio,name=virtio.0 -net
tap,fd=33,vlan=0,name=tap.0 -chardev pty,id=serial0 -serial chardev:serial0
-parallel none -usb -vnc 127.0.0.1:0 -vga cirrus -incoming tcp:0.0.0.0:49155
char device redirected to /dev/pts/2
I'm attaching the xml of the scompi1 that i'm trying to migrate.
I'd apprciate a lot any help.
Marcela
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: scompi1.xml
Type: text/xml
Size: 1292 bytes
Desc: not available
URL:
From berrange at redhat.com Mon Apr 4 10:20:13 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 11:20:13 +0100
Subject: [libvirt] Using Restore in another host.
In-Reply-To:
References:
Message-ID: <20110404102013.GB13616@redhat.com>
On Sun, Apr 03, 2011 at 10:43:45AM +0200, Marcela Castro Le?n wrote:
> Hello:
> I need to know if I can use the restore operation (virsh o the equivalent in
> libvirt) to recover a previous state of a guest, but recovered previously in
> another host.
> I did a test, but I got an error:
>
> The exactly sequence using virsh I testes is:
> On [HOST SOURCE]: Using virsh
> 1) save [domain] [file]
> 2) restore file
> 3) destroy [domain]
>
> On [HOST SOURCE] using ubuntu sh
> 4) cp [guest.img] [guest.xml] [file] to HOST2
>
> On [HOST TARGET] using virsh
> 5) define [guest.xml] (using image on destination in HOST2)
> 6) restore [file]
As a general rule you should only ever 'restore' from a
file *once*. This is because after the first restore
operation, the guest may have made writes to its disk.
Restoring a second time the guest OS will likely have
an inconsistent view of the disk & will cause filesystem
corruption.
If you want to be able to restore from a saved image
multiple times, you need to also take a snapshot of
the disk image at the same time, and restore that
snapshot when restoring the memory image.
That aside, saving on one host & restoring on a
different host is fine. So if you leave out steps
2+3 in your example above, then your data would
still be safe.
> The restore troughs the following message:
> *virsh # restore sv-chubut-2011-04-01-09:58
> error: Failed to restore domain from sv-chubut-2011-04-01-09:58
> error: monitor socket did not show up.: Connection refused*
There is probably some configuration difference on your 2nd host
that prevented the VM from starting up. If you're lucky the file
/var/log/libvirt/qemu/$NAME.log will tell you more
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From berrange at redhat.com Mon Apr 4 10:22:13 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 11:22:13 +0100
Subject: [libvirt] [PATCH 01/20] Remove PATH_MAX sized stack allocations
related to virFileBuildPath
In-Reply-To: <1301822493-23013-2-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
<1301822493-23013-2-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <20110404102213.GC13616@redhat.com>
On Sun, Apr 03, 2011 at 11:21:14AM +0200, Matthias Bolte wrote:
> Make virFileBuildPath operate on the heap instead of the stack. It
> allocates a buffer instead of expecting a preexisting buffer.
> ---
> src/conf/nwfilter_conf.c | 21 +++++++--------------
> src/conf/storage_conf.c | 44 +++++++++++++++-----------------------------
> src/util/util.c | 29 +++++++++++++++--------------
> src/util/util.h | 8 +++-----
> src/xen/xen_inotify.c | 16 +++++++++-------
> src/xen/xm_internal.c | 33 +++++++++++++++++----------------
> 6 files changed, 66 insertions(+), 85 deletions(-)
> - if (!(pool->autostartLink = strdup(path))) {
> + if (!(pool->autostartLink = virFileBuildPath(driver->autostartDir,
> + def->name, ".xml"))) {
> virReportOOMError();
> VIR_FREE(pool->configFile);
> return -1;
> diff --git a/src/util/util.c b/src/util/util.c
> index 43794b1..31feecc 100644
> --- a/src/util/util.c
> +++ b/src/util/util.c
> @@ -1841,23 +1841,24 @@ cleanup:
> return err;
> }
>
> -/* Build up a fully qualfiied path for a config file to be
> +/* Build up a fully qualified path for a config file to be
> * associated with a persistent guest or network */
> -int virFileBuildPath(const char *dir,
> - const char *name,
> - const char *ext,
> - char *buf,
> - unsigned int buflen)
> +char *
> +virFileBuildPath(const char *dir, const char *name, const char *ext)
> {
> - if ((strlen(dir) + 1 + strlen(name) + (ext ? strlen(ext) : 0) + 1) >= (buflen-1))
> - return -1;
> + char *path;
>
> - strcpy(buf, dir);
> - strcat(buf, "/");
> - strcat(buf, name);
> - if (ext)
> - strcat(buf, ext);
> - return 0;
> + if (ext == NULL) {
> + if (virAsprintf(&path, "%s/%s", dir, name) < 0) {
> + return NULL;
> + }
> + } else {
> + if (virAsprintf(&path, "%s/%s%s", dir, name, ext) < 0) {
> + return NULL;
> + }
> + }
> +
> + return path;
> }
ACK to the patch, but we might like to make virFileBuildPath invoke
virReportOOMError() itself as a followup, so callers don't have to
worry about it
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From berrange at redhat.com Mon Apr 4 10:23:21 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 11:23:21 +0100
Subject: [libvirt] [PATCH 02/20] pci: Remove PATH_MAX sized stack
allocations
In-Reply-To: <1301822493-23013-3-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
<1301822493-23013-3-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <20110404102321.GD13616@redhat.com>
On Sun, Apr 03, 2011 at 11:21:15AM +0200, Matthias Bolte wrote:
> Use virAsprintf instead of snprintf.
> ---
> src/util/pci.c | 172 +++++++++++++++++++++++++++++++++++++++++---------------
> 1 files changed, 127 insertions(+), 45 deletions(-)
ACK
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From berrange at redhat.com Mon Apr 4 10:24:02 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 11:24:02 +0100
Subject: [libvirt] [PATCH 03/20] ebtables: Remove PATH_MAX sized stack
allocation
In-Reply-To: <1301822493-23013-4-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
<1301822493-23013-4-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <20110404102402.GE13616@redhat.com>
On Sun, Apr 03, 2011 at 11:21:16AM +0200, Matthias Bolte wrote:
> ---
> src/util/ebtables.c | 44 +++++++++++++++++++++++++++++---------------
> 1 files changed, 29 insertions(+), 15 deletions(-)
ACK
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From berrange at redhat.com Mon Apr 4 10:24:56 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 11:24:56 +0100
Subject: [libvirt] [PATCH 04/20] virt-aa-helper: Remove PATH_MAX sized
stack allocations
In-Reply-To: <1301822493-23013-5-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
<1301822493-23013-5-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <20110404102456.GF13616@redhat.com>
On Sun, Apr 03, 2011 at 11:21:17AM +0200, Matthias Bolte wrote:
> ---
> src/security/virt-aa-helper.c | 46 +++++++++++++++++++++++++----------------
> 1 files changed, 28 insertions(+), 18 deletions(-)
ACK
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From berrange at redhat.com Mon Apr 4 10:25:27 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 11:25:27 +0100
Subject: [libvirt] [PATCH 05/20] phyp: Remove 16kb stack allocation
In-Reply-To: <1301822493-23013-6-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
<1301822493-23013-6-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <20110404102527.GG13616@redhat.com>
On Sun, Apr 03, 2011 at 11:21:18AM +0200, Matthias Bolte wrote:
> Allocate on the heap instead.
> ---
> src/phyp/phyp_driver.c | 13 +++++++++++--
> 1 files changed, 11 insertions(+), 2 deletions(-)
ACK
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From berrange at redhat.com Mon Apr 4 10:26:15 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 11:26:15 +0100
Subject: [libvirt] [PATCH 06/20] qemu: Use heap allocated memory to read
the monitor greeting
In-Reply-To: <1301822493-23013-7-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
<1301822493-23013-7-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <20110404102615.GH13616@redhat.com>
On Sun, Apr 03, 2011 at 11:21:19AM +0200, Matthias Bolte wrote:
> Removing a 4kb stack allocation.
>
> Reduce stack buffer for virStrerror to the common 1kb instead of 4kb.
> ---
> src/qemu/qemu_process.c | 16 ++++++++++++----
> 1 files changed, 12 insertions(+), 4 deletions(-)
ACK
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From berrange at redhat.com Mon Apr 4 10:27:17 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 11:27:17 +0100
Subject: [libvirt] [PATCH 07/20] sasl: Remove stack allocated 8kb
temporary buffers
In-Reply-To: <1301822493-23013-8-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
<1301822493-23013-8-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <20110404102717.GI13616@redhat.com>
On Sun, Apr 03, 2011 at 11:21:20AM +0200, Matthias Bolte wrote:
> Move the buffers to the heap allocated client/private data structs.
> ---
> daemon/libvirtd.c | 10 ++++++----
> daemon/libvirtd.h | 1 +
> src/remote/remote_driver.c | 8 +++++---
> 3 files changed, 12 insertions(+), 7 deletions(-)
ACK, I wouldn't have done it this way, but it doesn't matter because
this code will die very soon.
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From berrange at redhat.com Mon Apr 4 10:27:56 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 11:27:56 +0100
Subject: [libvirt] [PATCH 08/20] xenxs: Remove PATH_MAX sized stack
alocation in XM script parsing
In-Reply-To: <1301822493-23013-9-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
<1301822493-23013-9-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <20110404102755.GJ13616@redhat.com>
On Sun, Apr 03, 2011 at 11:21:21AM +0200, Matthias Bolte wrote:
> ---
> src/xenxs/xen_xm.c | 14 ++++++--------
> 1 files changed, 6 insertions(+), 8 deletions(-)
ACK
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From berrange at redhat.com Mon Apr 4 10:30:14 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 11:30:14 +0100
Subject: [libvirt] [PATCH 09/20] Use virFileAbsPath instead of manually
creating the absolute path
In-Reply-To: <1301822493-23013-10-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
<1301822493-23013-10-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <20110404103014.GK13616@redhat.com>
On Sun, Apr 03, 2011 at 11:21:22AM +0200, Matthias Bolte wrote:
> Removes multiple 4kb stack allocations.
> ---
> src/libvirt.c | 113 +++++++++++++++++++++------------------------------------
> 1 files changed, 42 insertions(+), 71 deletions(-)
>
> diff --git a/src/libvirt.c b/src/libvirt.c
> index 8be18d4..25f8d41 100644
> --- a/src/libvirt.c
> +++ b/src/libvirt.c
> @@ -2238,7 +2238,6 @@ error:
> int
> virDomainSave(virDomainPtr domain, const char *to)
> {
> - char filepath[4096];
> virConnectPtr conn;
>
> VIR_DOMAIN_DEBUG(domain, "to=%s", to);
> @@ -2260,29 +2259,24 @@ virDomainSave(virDomainPtr domain, const char *to)
> goto error;
> }
>
> - /*
> - * We must absolutize the file path as the save is done out of process
> - * TODO: check for URI when libxml2 is linked in.
> - */
> - if (to[0] != '/') {
> - unsigned int len, t;
> + if (conn->driver->domainSave) {
> + int ret;
> + char *absolute_to;
>
> - t = strlen(to);
> - if (getcwd(filepath, sizeof(filepath) - (t + 3)) == NULL)
> - return -1;
> - len = strlen(filepath);
> - /* that should be covered by getcwd() semantic, but be 100% sure */
> - if (len > sizeof(filepath) - (t + 3))
> - return -1;
> - filepath[len] = '/';
> - strcpy(&filepath[len + 1], to);
> - to = &filepath[0];
> + /*
> + * We must absolutize the file path as the save is done out of process
> + * TODO: check for URI when libxml2 is linked in.
> + */
> + if (virFileAbsPath(to, &absolute_to) < 0) {
> + virLibConnError(VIR_ERR_INTERNAL_ERROR,
> + _("could not build absolute output file path"));
> + goto error;
> + }
>
> - }
> + ret = conn->driver->domainSave(domain, absolute_to);
> +
> + VIR_FREE(absolute_to);
>
> - if (conn->driver->domainSave) {
> - int ret;
> - ret = conn->driver->domainSave (domain, to);
> if (ret < 0)
> goto error;
> return ret;
> @@ -2298,7 +2292,7 @@ error:
> /**
> * virDomainRestore:
> * @conn: pointer to the hypervisor connection
> - * @from: path to the
> + * @from: path to the input file
> *
> * This method will restore a domain saved to disk by virDomainSave().
> *
> @@ -2307,7 +2301,6 @@ error:
> int
> virDomainRestore(virConnectPtr conn, const char *from)
> {
> - char filepath[4096];
> VIR_DEBUG("conn=%p, from=%s", conn, from);
>
> virResetLastError();
> @@ -2326,34 +2319,24 @@ virDomainRestore(virConnectPtr conn, const char *from)
> goto error;
> }
>
> - /*
> - * We must absolutize the file path as the restore is done out of process
> - * TODO: check for URI when libxml2 is linked in.
> - */
> - if (from[0] != '/') {
> - unsigned int len, t;
> + if (conn->driver->domainRestore) {
> + int ret;
> + char *absolute_from;
>
> - t = strlen(from);
> - if (getcwd(filepath, sizeof(filepath) - (t + 3)) == NULL) {
> - virLibConnError(VIR_ERR_SYSTEM_ERROR,
> - _("cannot get working directory"));
> - goto error;
> - }
> - len = strlen(filepath);
> - /* that should be covered by getcwd() semantic, but be 100% sure */
> - if (len > sizeof(filepath) - (t + 3)) {
> + /*
> + * We must absolutize the file path as the restore is done out of process
> + * TODO: check for URI when libxml2 is linked in.
> + */
> + if (virFileAbsPath(from, &absolute_from) < 0) {
> virLibConnError(VIR_ERR_INTERNAL_ERROR,
> - _("path too long"));
> + _("could not build absolute input file path"));
> goto error;
> }
> - filepath[len] = '/';
> - strcpy(&filepath[len + 1], from);
> - from = &filepath[0];
> - }
>
> - if (conn->driver->domainRestore) {
> - int ret;
> - ret = conn->driver->domainRestore (conn, from);
> + ret = conn->driver->domainRestore(conn, absolute_from);
> +
> + VIR_FREE(absolute_from);
> +
> if (ret < 0)
> goto error;
> return ret;
> @@ -2381,7 +2364,6 @@ error:
> int
> virDomainCoreDump(virDomainPtr domain, const char *to, int flags)
> {
> - char filepath[4096];
> virConnectPtr conn;
>
> VIR_DOMAIN_DEBUG(domain, "to=%s, flags=%d", to, flags);
> @@ -2403,35 +2385,24 @@ virDomainCoreDump(virDomainPtr domain, const char *to, int flags)
> goto error;
> }
>
> - /*
> - * We must absolutize the file path as the save is done out of process
> - * TODO: check for URI when libxml2 is linked in.
> - */
> - if (to[0] != '/') {
> - unsigned int len, t;
> + if (conn->driver->domainCoreDump) {
> + int ret;
> + char *absolute_to;
>
> - t = strlen(to);
> - if (getcwd(filepath, sizeof(filepath) - (t + 3)) == NULL) {
> - virLibDomainError(VIR_ERR_SYSTEM_ERROR,
> - _("cannot get current directory"));
> - goto error;
> - }
> - len = strlen(filepath);
> - /* that should be covered by getcwd() semantic, but be 100% sure */
> - if (len > sizeof(filepath) - (t + 3)) {
> - virLibDomainError(VIR_ERR_INTERNAL_ERROR,
> - _("path too long"));
> + /*
> + * We must absolutize the file path as the save is done out of process
> + * TODO: check for URI when libxml2 is linked in.
> + */
> + if (virFileAbsPath(to, &absolute_to) < 0) {
> + virLibConnError(VIR_ERR_INTERNAL_ERROR,
> + _("could not build absolute core file path"));
> goto error;
> }
> - filepath[len] = '/';
> - strcpy(&filepath[len + 1], to);
> - to = &filepath[0];
>
> - }
> + ret = conn->driver->domainCoreDump(domain, absolute_to, flags);
> +
> + VIR_FREE(absolute_to);
>
> - if (conn->driver->domainCoreDump) {
> - int ret;
> - ret = conn->driver->domainCoreDump (domain, to, flags);
> if (ret < 0)
> goto error;
> return ret;
ACK, but you could kill those TODO: comments, since I don't think we
will ever let libvirt save to arbitrary URIs. If anything we would
introduce a different API using the virStreamPtr facility, so the
client app would deal with URIs as needed
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From berrange at redhat.com Mon Apr 4 10:31:27 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 11:31:27 +0100
Subject: [libvirt] [PATCH 10/20] virsh: Remove two 4kb stack allocations
In-Reply-To: <1301822493-23013-11-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
<1301822493-23013-11-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <20110404103127.GL13616@redhat.com>
On Sun, Apr 03, 2011 at 11:21:23AM +0200, Matthias Bolte wrote:
> ---
> tools/virsh.c | 23 +++++++++++++++++------
> 1 files changed, 17 insertions(+), 6 deletions(-)
ACK
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From berrange at redhat.com Mon Apr 4 10:35:18 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 11:35:18 +0100
Subject: [libvirt] [PATCH 11/20] phyp: Remove the last instance of stack
allocating a 4kb volume key
In-Reply-To: <1301822493-23013-12-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
<1301822493-23013-12-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <20110404103518.GM13616@redhat.com>
On Sun, Apr 03, 2011 at 11:21:24AM +0200, Matthias Bolte wrote:
> ---
> src/phyp/phyp_driver.c | 13 +++++++++++--
> 1 files changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
> index fe2e99d..76207c2 100644
> --- a/src/phyp/phyp_driver.c
> +++ b/src/phyp/phyp_driver.c
> @@ -2362,13 +2362,22 @@ phypBuildVolume(virConnectPtr conn, const char *lvname, const char *spname,
> static virStorageVolPtr
> phypVolumeLookupByName(virStoragePoolPtr pool, const char *volname)
> {
> + char *key;
> + virStorageVolPtr vol;
>
> - char key[MAX_KEY_SIZE];
> + if (VIR_ALLOC_N(key, MAX_KEY_SIZE) < 0) {
> + virReportOOMError();
> + return NULL;
> + }
>
> if (phypVolumeGetKey(pool->conn, key, volname) == -1)
> return NULL;
>
> - return virGetStorageVol(pool->conn, pool->name, volname, key);
> + vol = virGetStorageVol(pool->conn, pool->name, volname, key);
> +
> + VIR_FREE(key);
> +
> + return vol;
> }
I think the signature of phypVolumeGetKey() is rather dangerous - it is
blindly assuming the caller allocates MAX_KEY_SIZE for 'key'. The
phypVolumeGetKey knows exactly how long the key it has is, so it'd be
better for it to allocate the buffer itself & return it to the callers
I realize this isn't a new problem from your patch, but I reckon we
should fix it here.
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From berrange at redhat.com Mon Apr 4 10:35:53 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 11:35:53 +0100
Subject: [libvirt] [PATCH 12/20] daemon: Remove 4kb stack allocation of
security label
In-Reply-To: <1301822493-23013-13-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
<1301822493-23013-13-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <20110404103553.GN13616@redhat.com>
On Sun, Apr 03, 2011 at 11:21:25AM +0200, Matthias Bolte wrote:
> ---
> daemon/remote.c | 20 ++++++++++++++------
> 1 files changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/daemon/remote.c b/daemon/remote.c
> index 1700c2d..dd85ef1 100644
> --- a/daemon/remote.c
> +++ b/daemon/remote.c
> @@ -1607,7 +1607,7 @@ remoteDispatchDomainGetSecurityLabel(struct qemud_server *server ATTRIBUTE_UNUSE
> remote_domain_get_security_label_ret *ret)
> {
> virDomainPtr dom;
> - virSecurityLabel seclabel;
> + virSecurityLabelPtr seclabel;
>
> dom = get_nonnull_domain(conn, args->dom);
> if (dom == NULL) {
> @@ -1615,22 +1615,30 @@ remoteDispatchDomainGetSecurityLabel(struct qemud_server *server ATTRIBUTE_UNUSE
> return -1;
> }
>
> - memset(&seclabel, 0, sizeof seclabel);
> - if (virDomainGetSecurityLabel(dom, &seclabel) == -1) {
> + if (VIR_ALLOC(seclabel) < 0) {
> + virDomainFree(dom);
> + remoteDispatchOOMError(rerr);
> + return -1;
> + }
> +
> + if (virDomainGetSecurityLabel(dom, seclabel) == -1) {
> remoteDispatchConnError(rerr, conn);
> virDomainFree(dom);
> + VIR_FREE(seclabel);
> return -1;
> }
>
> - ret->label.label_len = strlen(seclabel.label) + 1;
> + ret->label.label_len = strlen(seclabel->label) + 1;
> if (VIR_ALLOC_N(ret->label.label_val, ret->label.label_len) < 0) {
> virDomainFree(dom);
> + VIR_FREE(seclabel);
> remoteDispatchOOMError(rerr);
> return -1;
> }
> - strcpy(ret->label.label_val, seclabel.label);
> - ret->enforcing = seclabel.enforcing;
> + strcpy(ret->label.label_val, seclabel->label);
> + ret->enforcing = seclabel->enforcing;
> virDomainFree(dom);
> + VIR_FREE(seclabel);
>
> return 0;
> }
ACK
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From berrange at redhat.com Mon Apr 4 10:37:20 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 11:37:20 +0100
Subject: [libvirt] [PATCH 13/20] openvz: Remove several larger stack
allocations
In-Reply-To: <1301822493-23013-14-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
<1301822493-23013-14-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <20110404103720.GO13616@redhat.com>
On Sun, Apr 03, 2011 at 11:21:26AM +0200, Matthias Bolte wrote:
> Replace openvz_readline with getline in several places to get rid of stack
> allocated buffers to hold lines.
>
> openvzReadConfigParam allocates memory for return values instead of
> expecting a preexisting buffer.
> ---
> src/openvz/openvz_conf.c | 141 +++++++++++++++++++++++++++-----------------
> src/openvz/openvz_conf.h | 2 +-
> src/openvz/openvz_driver.c | 45 +++++++++-----
> 3 files changed, 117 insertions(+), 71 deletions(-)
ACK
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From berrange at redhat.com Mon Apr 4 10:38:05 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 11:38:05 +0100
Subject: [libvirt] [PATCH 14/20] Remove PATH_MAX sized stack allocation
from virFileOpenTtyAt
In-Reply-To: <1301822493-23013-15-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
<1301822493-23013-15-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <20110404103805.GP13616@redhat.com>
On Sun, Apr 03, 2011 at 11:21:27AM +0200, Matthias Bolte wrote:
> ---
> src/util/util.c | 9 ++++-----
> 1 files changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/src/util/util.c b/src/util/util.c
> index 31feecc..c0391ad 100644
> --- a/src/util/util.c
> +++ b/src/util/util.c
> @@ -1901,14 +1901,13 @@ int virFileOpenTtyAt(const char *ptmx,
> }
>
> if (ttyName) {
> - char tempTtyName[PATH_MAX];
> - if (ptsname_r(*ttymaster, tempTtyName, sizeof(tempTtyName)) < 0)
> - goto cleanup;
> -
> - if ((*ttyName = strdup(tempTtyName)) == NULL) {
> + if (VIR_ALLOC_N(*ttyName, PATH_MAX) < 0) {
> errno = ENOMEM;
> goto cleanup;
> }
> +
> + if (ptsname_r(*ttymaster, *ttyName, PATH_MAX) < 0)
> + goto cleanup;
> }
ACK
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From berrange at redhat.com Mon Apr 4 10:38:49 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 11:38:49 +0100
Subject: [libvirt] [PATCH 15/20] qemu: Remove PATH_MAX sized stack
allocation used in commandline building
In-Reply-To: <1301822493-23013-16-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
<1301822493-23013-16-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <20110404103849.GQ13616@redhat.com>
On Sun, Apr 03, 2011 at 11:21:28AM +0200, Matthias Bolte wrote:
> ---
> src/qemu/qemu_command.c | 43 ++++++++++++++++++++++++++++++-------------
> 1 files changed, 30 insertions(+), 13 deletions(-)
ACK
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From berrange at redhat.com Mon Apr 4 10:40:23 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 11:40:23 +0100
Subject: [libvirt] [PATCH 16/20] xen: Remove PATH_MAX sized stack
allocation from block stats code
In-Reply-To: <1301822493-23013-17-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
<1301822493-23013-17-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <20110404104023.GR13616@redhat.com>
On Sun, Apr 03, 2011 at 11:21:29AM +0200, Matthias Bolte wrote:
> ---
> src/xen/block_stats.c | 52 +++++++++++++++++++++++++-----------------------
> 1 files changed, 27 insertions(+), 25 deletions(-)
>
> diff --git a/src/xen/block_stats.c b/src/xen/block_stats.c
> index e7c80c9..6b4171d 100644
> --- a/src/xen/block_stats.c
> +++ b/src/xen/block_stats.c
> @@ -113,34 +113,36 @@ read_stat (const char *path)
> }
>
> static int64_t
> -read_bd_stat (int device, int domid, const char *str)
> +read_bd_stat(int device, int domid, const char *str)
> {
> - char path[PATH_MAX];
> + static const char *paths[] = {
> + "/sys/bus/xen-backend/devices/vbd-%d-%d/statistics/%s",
> + "/sys/bus/xen-backend/devices/tap-%d-%d/statistics/%s",
> + "/sys/devices/xen-backend/vbd-%d-%d/statistics/%s",
> + "/sys/devices/xen-backend/tap-%d-%d/statistics/%s",
> + NULL
> + };
If you leave out the trailing NULL
> +
> + int i;
> + char *path;
> int64_t r;
>
> - snprintf (path, sizeof path,
> - "/sys/bus/xen-backend/devices/vbd-%d-%d/statistics/%s",
> - domid, device, str);
> - r = read_stat (path);
> - if (r >= 0) return r;
> -
> - snprintf (path, sizeof path,
> - "/sys/bus/xen-backend/devices/tap-%d-%d/statistics/%s",
> - domid, device, str);
> - r = read_stat (path);
> - if (r >= 0) return r;
> -
> - snprintf (path, sizeof path,
> - "/sys/devices/xen-backend/vbd-%d-%d/statistics/%s",
> - domid, device, str);
> - r = read_stat (path);
> - if (r >= 0) return r;
> -
> - snprintf (path, sizeof path,
> - "/sys/devices/xen-backend/tap-%d-%d/statistics/%s",
> - domid, device, str);
> - r = read_stat (path);
> - return r;
> + for (i = 0; paths[i] != NULL; ++i) {
you can just use for (i = 0 ; i < ARRAY_CARDINALITY(paths) ; i++)
which I find slightly clearer.
> + if (virAsprintf(&path, paths[i], domid, device, str) < 0) {
> + virReportOOMError();
> + return -1;
> + }
> +
> + r = read_stat(path);
> +
> + VIR_FREE(path);
> +
> + if (r >= 0) {
> + return r;
> + }
> + }
> +
> + return -1;
> }
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From berrange at redhat.com Mon Apr 4 10:41:12 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 11:41:12 +0100
Subject: [libvirt] [PATCH 17/20] storage: Remove PATH_MAX sized stack
allocation from iSCSI backend
In-Reply-To: <1301822493-23013-18-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
<1301822493-23013-18-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <20110404104112.GS13616@redhat.com>
On Sun, Apr 03, 2011 at 11:21:30AM +0200, Matthias Bolte wrote:
> ---
> src/storage/storage_backend_iscsi.c | 11 ++++++++---
> 1 files changed, 8 insertions(+), 3 deletions(-)
ACK
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From berrange at redhat.com Mon Apr 4 10:41:37 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 11:41:37 +0100
Subject: [libvirt] [PATCH 18/20] uml: Remove PATH_MAX sized stack
allocation from /proc parsing code
In-Reply-To: <1301822493-23013-19-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
<1301822493-23013-19-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <20110404104137.GT13616@redhat.com>
On Sun, Apr 03, 2011 at 11:21:31AM +0200, Matthias Bolte wrote:
> ---
> src/uml/uml_driver.c | 10 +++++++---
> 1 files changed, 7 insertions(+), 3 deletions(-)
ACK
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From berrange at redhat.com Mon Apr 4 10:42:11 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 11:42:11 +0100
Subject: [libvirt] [PATCH 19/20] xend: Remove 4kb stack allocation
In-Reply-To: <1301822493-23013-20-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
<1301822493-23013-20-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <20110404104211.GU13616@redhat.com>
On Sun, Apr 03, 2011 at 11:21:32AM +0200, Matthias Bolte wrote:
> ---
> src/xen/xend_internal.c | 12 ++++++++++--
> 1 files changed, 10 insertions(+), 2 deletions(-)
ACK
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From berrange at redhat.com Mon Apr 4 10:43:05 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 11:43:05 +0100
Subject: [libvirt] [PATCH 20/20] Use virBufferPtr for sexpr2string
instead of manual buffer handling
In-Reply-To: <1301822493-23013-21-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
<1301822493-23013-21-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <20110404104305.GV13616@redhat.com>
On Sun, Apr 03, 2011 at 11:21:33AM +0200, Matthias Bolte wrote:
> Removes 4kb stack allocation in the XenD subdriver.
> ---
> src/util/sexpr.c | 142 +++++++++++++++++++++++------------------------
> src/util/sexpr.h | 3 +-
> src/xen/xend_internal.c | 17 +++++-
> 3 files changed, 86 insertions(+), 76 deletions(-)
ACK
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From berrange at redhat.com Mon Apr 4 10:44:23 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 11:44:23 +0100
Subject: [libvirt] [PATCH 00/20] Remove large stack allocations
In-Reply-To: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
Message-ID: <20110404104423.GW13616@redhat.com>
On Sun, Apr 03, 2011 at 11:21:13AM +0200, Matthias Bolte wrote:
> This is meant for post-0.9.0.
>
> The series removes many large stack allocations from the code base and makes
> it compile with -Wframe-larger-than=2500. This was inspired by Dan's patch for
> using gnulib's manywarnings & warnings modules [1]. Where he mentioned that
> currently -Wframe-larger-than=20480 is required.
>
> This series doesn't address stack usage in the test suite.
I've ACKd most of the patches - feel free to push those after the release
& just repost the couple which had comments, rather than the whole series.
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From berrange at redhat.com Mon Apr 4 10:47:53 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 11:47:53 +0100
Subject: [libvirt] [Qemu-devel] [PATCH v2 3/3] raw-posix: Re-open host
CD-ROM after media change
In-Reply-To:
References: <1301425482-8722-1-git-send-email-stefanha@linux.vnet.ibm.com>
<1301425482-8722-4-git-send-email-stefanha@linux.vnet.ibm.com>
Message-ID: <20110404104753.GX13616@redhat.com>
On Sun, Apr 03, 2011 at 07:06:17PM +0100, Stefan Hajnoczi wrote:
> On Sun, Apr 3, 2011 at 2:12 PM, Blue Swirl wrote:
> > On Sun, Apr 3, 2011 at 2:57 PM, Stefan Hajnoczi wrote:
> >> On Tue, Mar 29, 2011 at 8:04 PM, Stefan Hajnoczi
> >> wrote:
> >>> Piggy-back on the guest CD-ROM polling to poll on the host. ?Open and
> >>> close the host CD-ROM file descriptor to ensure we read the new size and
> >>> not a stale size.
> >>>
> >>> Two things are going on here:
> >>>
> >>> 1. If hald/udisks is not already polling CD-ROMs on the host then
> >>> ? re-opening the CD-ROM causes the host to read the new medium's size.
> >>>
> >>> 2. There is a bug in Linux which means the CD-ROM file descriptor must
> >>> ? be re-opened in order for lseek(2) to see the new size. ?The
> >>> ? inode size gets out of sync with the underlying device (which you can
> >>> ? confirm by checking that /sys/block/sr0/size and lseek(2) do not
> >>> ? match after media change). ?I have raised this with the
> >>> ? maintainers but we need a workaround for the foreseeable future.
> >>>
> >>> Note that these changes are all in a #ifdef __linux__ section.
> >>>
> >>> Signed-off-by: Stefan Hajnoczi
> >>> ---
> >>> ?block/raw-posix.c | ? 26 ++++++++++++++++++++++----
> >>> ?1 files changed, 22 insertions(+), 4 deletions(-)
> >>>
> >>> diff --git a/block/raw-posix.c b/block/raw-posix.c
> >>> index 6b72470..8b5205c 100644
> >>> --- a/block/raw-posix.c
> >>> +++ b/block/raw-posix.c
> >>> @@ -1238,10 +1238,28 @@ static int cdrom_is_inserted(BlockDriverState *bs)
> >>> ? ? BDRVRawState *s = bs->opaque;
> >>> ? ? int ret;
> >>>
> >>> - ? ?ret = ioctl(s->fd, CDROM_DRIVE_STATUS, CDSL_CURRENT);
> >>> - ? ?if (ret == CDS_DISC_OK)
> >>> - ? ? ? ?return 1;
> >>> - ? ?return 0;
> >>> + ? ?/*
> >>> + ? ? * Close the file descriptor if no medium is present and open it to poll
> >>> + ? ? * again. ?This ensures the medium size is refreshed. ?If the file
> >>> + ? ? * descriptor is kept open the size can become stale. ?This is essentially
> >>> + ? ? * replicating CD-ROM polling but is driven by the guest. ?As the guest
> >>> + ? ? * polls, we poll the host.
> >>> + ? ? */
> >>> +
> >>> + ? ?if (s->fd == -1) {
> >>> + ? ? ? ?s->fd = qemu_open(bs->filename, s->open_flags, 0644);
> >>> + ? ? ? ?if (s->fd < 0) {
> >>> + ? ? ? ? ? ?return 0;
> >>> + ? ? ? ?}
> >>> + ? ?}
> >>> +
> >>> + ? ?ret = (ioctl(s->fd, CDROM_DRIVE_STATUS, CDSL_CURRENT) == CDS_DISC_OK);
> >>> +
> >>> + ? ?if (!ret) {
> >>> + ? ? ? ?close(s->fd);
> >>> + ? ? ? ?s->fd = -1;
> >>> + ? ?}
> >>> + ? ?return ret;
> >>> ?}
> >>>
> >>> ?static int cdrom_eject(BlockDriverState *bs, int eject_flag)
> >>> --
> >>> 1.7.4.1
> >>>
> >>>
> >>>
> >>
> >> There is an issue with reopening host devices in QEMU when running
> >> under libvirt. ?It appears that libvirt chowns image files (including
> >> device nodes) so that the launched QEMU process can access them.
> >>
> >> Unfortunately after media change on host devices udev will reset the
> >> ownership of the device node. ?This causes open(2) to fail with EACCES
> >> since the QEMU process does not have the right uid/gid/groups and
> >> libvirt is unaware that the file's ownership has changed.
> >>
> >> In order for media change to work with Linux host CD-ROM it is
> >> necessary to reopen the file (otherwise the inode size will not
> >> refresh, this is an issue with existing kernels).
> >>
> >> How can libvirt's security model be made to support this case? ?In
> >> theory udev could be temporarily configured with libvirt permissions
> >> for the CD-ROM device while passed through to the guest, but is that
> >> feasible?
> >
> > How about something like this: Add an explicit reopen method to
> > BlockDriver. Make a special block device for passed file descriptors.
> > Pass descriptors in libvirt for CD-ROMs instead of the device paths.
> > The reopen method for file descriptors should notify libvirt about
> > need to pass a reopened descriptor and then block all accesses until a
> > new descriptor is available. This should also solve your earlier
> > problem.
>
> I'm hoping libvirt's behavior can be made to just work rather than
> adding new features to QEMU. But perhaps passing file descriptors is
> useful for more than just reopening host devices. This would
> basically be a privilege separation model where the QEMU process isn't
> able to open files itself but can request libvirt to open them on its
> behalf.
It is rather frickin' annoying the way udev resets the ownership
when the media merely changes. If it isn't possible to stop udev
doing this, then i think the only practical thing is to use ACLs
instead of user/group ownership. We wanted to switch to ACLs in
libvirt for other reasons already, but it isn't quite as simple
as it sounds[1] so we've not done it just yet.
Daniel
[1] Mostly due to handling upgrades from existing libvirtd while
VMs are running, and coping with filesystems which don't
support ACLs (or have them turned of by mount options)
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From berrange at redhat.com Mon Apr 4 10:50:13 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 11:50:13 +0100
Subject: [libvirt] FYI, "Unable to create cgroup for ..."
In-Reply-To: <87k4fixf0f.fsf@rho.meyering.net>
References: <87k4fixf0f.fsf@rho.meyering.net>
Message-ID: <20110404105013.GY13616@redhat.com>
On Tue, Mar 29, 2011 at 02:55:28PM +0200, Jim Meyering wrote:
> In case someone else encounters this...
>
> Today none of my VMs would start on F15:
>
> # virsh create rawhide.xml
> error: Failed to create domain from rawhide.xml
> error: Unable to create cgroup for rawhide: No such file or directory
>
> Luckily, I noticed that Rich Jones had the same problem
> a week ago and he found that restarting libvirtd was enough
> to solve the problem:
>
> # service libvirtd restart
>
> That did it for me, too.
This is a bug in systemd. It periodically scans all mounted cgroups
and deletes any directories which don't contain any attached processes.
Needless to say this breaks libvirt, and possibly other apps, which
don't expect 3rd parties to be deleting their directories.
https://bugzilla.redhat.com/show_bug.cgi?id=678555
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From jclift at redhat.com Mon Apr 4 10:59:58 2011
From: jclift at redhat.com (Justin Clift)
Date: Mon, 4 Apr 2011 20:59:58 +1000
Subject: [libvirt] [Libvirt-announce] 0.9.0 freeze week,
RC2 version to test
In-Reply-To: <883C8F48-51DF-4514-AC21-AA7397EE741A@redhat.com>
References: <20110328062538.GB7346@redhat.com>
<20110329144659.GD25888@redhat.com>
<20110331134423.GK24425@redhat.com>
<305053C1-65ED-4BCA-99CF-15927F4B31E9@redhat.com>
<883C8F48-51DF-4514-AC21-AA7397EE741A@redhat.com>
Message-ID: <788B08A8-35E5-4B62-A3C9-4984DE63D5AD@redhat.com>
On 04/04/2011, at 8:51 PM, Justin Clift wrote:
> On 02/04/2011, at 6:34 PM, Matthias Bolte wrote:
>
>>> Thanks. It's looking like some kind of problem interacting with
>>> VirtualBox (v4.0.4):
>>
>>> This is the full gdb backtrace from the process:
>>>
>>> (gdb) thread apply all bt
>>>
>>> Thread 1 (process 85784):
>>> #0 0x00007fff8549b3a6 in swtch_pri ()
>>> #1 0x00007fff854d5b51 in _pthread_find_thread ()
>
>> Strange point to get stuck.
>>
>> I assume VirtualBox for OSX comes with it's own GUI tool. Is it also
>> affected or only virsh?
>>
>> Does this happen with VirtualBox 4.0.4 only, or is 4.x or even 3.x affected too?
>
> Just tried with the earlier versions of 4.0.2 and 3.2.12, with full libvirt
> autogen.sh and recompile after each installation. Exact same behaviour, hang
> point, everything. :(
>
> The VirtualBox GUI seems completely unaffected. While virsh is stuck, the
> GUI can be started, VM's started/stopped, GUI shut down, all as per normal.
>
> I guess this is going to take a bunch more debugging, which I personally don't
> have the time for atm. (ugh) :(
>
> Are there any other OSX users around that could take a look?
As additional info, connecting to a remote RHEL 6.0 libvirtd using ssh works:
$ tools/virsh -c qemu+ssh://root at servername/system?socket=/var/run/libvirt/libvirt-sock
root at servername's password:
Welcome to virsh, the virtualization interactive terminal.
Type: 'help' for help with commands
'quit' to quit
virsh # ^D
$
Which is nice, as from memory it didn't used to (for ssh specifically).
+ Justin
From jim at meyering.net Mon Apr 4 11:24:09 2011
From: jim at meyering.net (Jim Meyering)
Date: Mon, 04 Apr 2011 13:24:09 +0200
Subject: [libvirt] FYI, "Unable to create cgroup for ..."
In-Reply-To: <20110404105013.GY13616@redhat.com> (Daniel P. Berrange's message
of "Mon, 4 Apr 2011 11:50:13 +0100")
References: <87k4fixf0f.fsf@rho.meyering.net>
<20110404105013.GY13616@redhat.com>
Message-ID: <87bp0m9s4m.fsf@rho.meyering.net>
Daniel P. Berrange wrote:
> On Tue, Mar 29, 2011 at 02:55:28PM +0200, Jim Meyering wrote:
>> In case someone else encounters this...
>>
>> Today none of my VMs would start on F15:
>>
>> # virsh create rawhide.xml
>> error: Failed to create domain from rawhide.xml
>> error: Unable to create cgroup for rawhide: No such file or directory
>>
>> Luckily, I noticed that Rich Jones had the same problem
>> a week ago and he found that restarting libvirtd was enough
>> to solve the problem:
>>
>> # service libvirtd restart
>>
>> That did it for me, too.
>
> This is a bug in systemd. It periodically scans all mounted cgroups
> and deletes any directories which don't contain any attached processes.
> Needless to say this breaks libvirt, and possibly other apps, which
> don't expect 3rd parties to be deleting their directories.
>
> https://bugzilla.redhat.com/show_bug.cgi?id=678555
Thanks.
With that, it's sure to be fixed soon.
From berrange at redhat.com Mon Apr 4 11:34:53 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 12:34:53 +0100
Subject: [libvirt] [PATCH] add sendevent command and related APIs
In-Reply-To: <4D95A00A.3040901@cn.fujitsu.com>
References: <4D95A00A.3040901@cn.fujitsu.com>
Message-ID: <20110404113453.GZ13616@redhat.com>
On Fri, Apr 01, 2011 at 05:51:06PM +0800, Lai Jiangshan wrote:
> Enable libvirt send some events to the guest.
> This command currently only supports NMI and key events.
>
> Signed-off-by: Lai Jiangshan
> ---
> daemon/remote.c | 52 +++++++++++++++++++++
> daemon/remote_dispatch_args.h | 2
> daemon/remote_dispatch_prototypes.h | 16 ++++++
> daemon/remote_dispatch_table.h | 10 ++++
> include/libvirt/libvirt.h.in | 3 +
> src/driver.h | 7 ++
> src/esx/esx_driver.c | 2
> src/libvirt.c | 88 ++++++++++++++++++++++++++++++++++++
> src/libvirt_public.syms | 2
> src/libxl/libxl_driver.c | 2
> src/lxc/lxc_driver.c | 2
> src/openvz/openvz_driver.c | 2
> src/phyp/phyp_driver.c | 4 +
> src/qemu/qemu_driver.c | 86 +++++++++++++++++++++++++++++++++++
> src/qemu/qemu_monitor.c | 27 +++++++++++
> src/qemu/qemu_monitor.h | 3 +
> src/qemu/qemu_monitor_json.c | 68 +++++++++++++++++++++++++++
> src/qemu/qemu_monitor_json.h | 3 +
> src/qemu/qemu_monitor_text.c | 56 ++++++++++++++++++++++
> src/qemu/qemu_monitor_text.h | 2
> src/remote/remote_driver.c | 50 ++++++++++++++++++++
> src/remote/remote_protocol.c | 22 +++++++++
> src/remote/remote_protocol.h | 19 +++++++
> src/remote/remote_protocol.x | 14 +++++
> src/test/test_driver.c | 2
> src/uml/uml_driver.c | 2
> src/vbox/vbox_tmpl.c | 2
> src/vmware/vmware_driver.c | 2
> src/xen/xen_driver.c | 2
> src/xenapi/xenapi_driver.c | 2
> tools/virsh.c | 56 ++++++++++++++++++++++
> 31 files changed, 608 insertions(+), 2 deletions(-)
> diff --git a/src/libvirt.c b/src/libvirt.c
> index 9bdb4c8..245247f 100644
> --- a/src/libvirt.c
> +++ b/src/libvirt.c
> @@ -5245,6 +5245,94 @@ error:
> }
>
> /**
> + * virDomainSendEvnetNMI:
> + * @domain: pointer to domain object, or NULL for Domain0
> + * @vcpu: the virtual CPU id to send NMI to
> + *
> + * Send NMI to a special vcpu of the guest
> + *
> + * Returns 0 in case of success, -1 in case of failure.
> + */
> +
> +int virDomainSendEventNMI(virDomainPtr domain, unsigned int vcpu)
Your proposal to qemu-devel to add inject-nmi for QMP does not
include any CPU index parameter anymore. Instead it will automatically
inject the NMI to all present CPUs. This libvirt API would appear to
be incompatible with that QMP design. For Xen, it appears the API
also does not allow a CPU index to be given - it just injects to the
first CPU AFAICT.
So do we really need to have a 'unsigned int vcpu' parameter in the
libvirt API, or can we just leave it out and always inject to
CPU==0 for HMP ?
eg simplify to
int virDomainSendNMI(virDomainPtr domain)
> +{
> + virConnectPtr conn;
> + VIR_DOMAIN_DEBUG(domain, "vcpu=%u", vcpu);
> +
> + virResetLastError();
> +
> + if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
> + virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
> + virDispatchError(NULL);
> + return (-1);
> + }
> + if (domain->conn->flags & VIR_CONNECT_RO) {
> + virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__);
> + goto error;
> + }
> +
> + conn = domain->conn;
> +
> + if (conn->driver->domainSendEventNMI) {
> + int ret;
> + ret = conn->driver->domainSendEventNMI(domain, vcpu);
> + if (ret < 0)
> + goto error;
> + return ret;
> + }
> +
> + virLibConnError (VIR_ERR_NO_SUPPORT, __FUNCTION__);
> +
> +error:
> + virDispatchError(domain->conn);
> + return -1;
> +}
> +
> +/**
> + * virDomainSendEventKey:
> + * @domain: pointer to domain object, or NULL for Domain0
> + * @key: the string of key or key sequence
> + *
> + * Send a special key or key sequence to the guest
> + *
> + * Returns 0 in case of success, -1 in case of failure.
> + */
> +
> +int virDomainSendEventKey(virDomainPtr domain, const char *key)
I don't entirely like that the 'const char *key' is just directly
exposing QEMU key names and combining syntax eg "ctrl-alt-delete".
The names are symbolic names for XT scancodes, which QEMU uses
internally as its master scancode set (regardless of arch or
whether the keyboard is actually XT based).
The VirtualBox API, requires that the application send an array
of integer scancodes.
The QEMU 'sendkey' command also has another 'holdtime' parameter
which controls how long QEMU waits between the 'press' and
'release' of the keys, which our API does not have.
The core requirement is that our API be able to send any possible
key, to any hypervisor.
The problem with XT scancodes, is that while it can be made to
represent any possible scancode, it gets somewhat confusing for
apps because there are many different ways to represent extended
scancodes in use across apps.
One alternative would be to duplicate Linux's virtual scancode
constants, which are a superset of all known possible scancode
lists. Then we would do a conversion inside libvirt from Linux
to hypervisor specific scancode format (probably XT values, or
XT strings).
The interesting thing about using Linux virtual scancode constants
is that this includes mouse buttons. So the same API could be
used to inject mouse clicks. We'd still need an explicit API for
doing mouse events though, because we'd need to be able to press
buttons, then generate motion events, then release buttons.
So, my preference would be for an API
virDomainSendKey(virDomainPtr dom,
unsigned int nkeycodes,
unsigned int keycodes,
unsigned int holdtime);
If "holdtime" is zero, then the hypervisor default behaviour
would be used. This allows us to support VirtualBox where
we'd have to reject any non-zero "holdtime" value
Then I think I'd create a new header file include/libvirt/virtkeys.h
which contained a copy of only the KEY_* constants from:
/usr/include/linux/input.h
We'd just have a static array with a mapping from keys to the QEMU
keycode names.
> diff --git a/tools/virsh.c b/tools/virsh.c
> index faeaf47..0b78c6d 100644
> --- a/tools/virsh.c
> +++ b/tools/virsh.c
> @@ -2910,6 +2910,61 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
> }
>
> /*
> + * "sendevent" command
> + */
> +static const vshCmdInfo info_sendevent[] = {
> + {"help", N_("send events to the guest")},
> + {"desc", N_("Send events (NMI or Keys) to the guest domain.")},
> + {NULL, NULL}
> +};
> +
> +static const vshCmdOptDef opts_sendevent[] = {
> + {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
> + {"eventtype", VSH_OT_DATA, VSH_OFLAG_REQ, N_("the type of event (nmi or key)")},
> + {"eventcontent", VSH_OT_DATA, VSH_OFLAG_REQ, N_("content for the event.")},
> + {NULL, 0, 0, NULL}
> +};
> +
> +
> +static int
> +cmdSendEvent(vshControl *ctl, const vshCmd *cmd)
> +{
> + virDomainPtr dom;
> + const char *type;
> + int ret = TRUE;
> +
> + if (!vshConnectionUsability(ctl, ctl->conn))
> + return FALSE;
> +
> + if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
> + return FALSE;
> +
> + if (vshCommandOptString(cmd, "eventtype", &type) < 0)
> + return FALSE;
> +
> + if (STREQ(type, "nmi")) {
> + int cpu;
> +
> + if ((vshCommandOptInt(cmd, "eventcontent", &cpu) < 0)
> + || (virDomainSendEventNMI(dom, cpu) < 0))
> + ret = FALSE;
> + } else if (STREQ(type, "key")) {
> + const char *key;
> +
> + if ((vshCommandOptString(cmd, "eventcontent", &key) < 0)
> + || (virDomainSendEventKey(dom, key) < 0))
> + ret = FALSE;
> + } else {
> + virDomainFree(dom);
> + vshError(ctl, _("Invalid event type: %s, only \"nmi\" or \"key\" supported currently."), type);
> + return FALSE;
> + }
> +
> + virDomainFree(dom);
> + return ret;
> +}
I don't like the way two APIs are combined into one virsh command.
Particularly since I think we'll likely add another API 'virDomainSendPointer'
which will take as many as 4/5 parameters, instead of just one.
Thus I think it would be better to have
virsh send-nmi
virsh send-key [--holdtime millsec] [ ...]
virsh send-pointer ...
virsh send-..... etc...
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From berrange at redhat.com Mon Apr 4 11:50:43 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 12:50:43 +0100
Subject: [libvirt] [PATCH 1/6] virNodeGetCpuTime: Expose new API
In-Reply-To: <20110404110310.e85d09ba.usui@mxm.nes.nec.co.jp>
References: <20110401103833.8b66b57e.usui@mxm.nes.nec.co.jp>
<20110401105548.a78607f7.usui@mxm.nes.nec.co.jp>
<4D95FB08.20802@redhat.com>
<20110404110310.e85d09ba.usui@mxm.nes.nec.co.jp>
Message-ID: <20110404115043.GA13616@redhat.com>
On Mon, Apr 04, 2011 at 11:03:10AM +0900, Minoru Usui wrote:
> Hi, Matthias.
>
> On Fri, 1 Apr 2011 20:22:17 +0200
> Matthias Bolte wrote:
>
> > 2011/4/1 Eric Blake :
> > > On 03/31/2011 07:55 PM, Minoru Usui wrote:
> > >> virNodeGetCpuTime: Expose new API
> > >>
> > >> ?include/libvirt/libvirt.h.in | ? 26 ++++++++++++++++++++++++++
> > >> ?src/libvirt_public.syms ? ? ?| ? ?1 +
> > >> ?2 files changed, 27 insertions(+), 0 deletions(-)
> > >
> > >>
> > >> +/**
> > >> + * virNodeCpuTime:
> > >> + *
> > >> + * a virNodeCpuTime is a structure filled by virNodeGetCpuTime() and providing
> > >> + * the information for the cpu time of Node.
> > >> + */
> > >> +
> > >> +typedef struct _virNodeCpuTime virNodeCpuTime;
> > >> +
> > >> +struct _virNodeCpuTime {
> > >> + ? ?unsigned long long user;
> > >> + ? ?unsigned long long system;
> > >> + ? ?unsigned long long idle;
> > >> + ? ?unsigned long long iowait;
> > >> +};
> > >
> > > Can we portably get all of this information on Windows? ?If not, how do
> > > you express which values we don't know how to obtain?
> > >
> >
> > In the context of ESX I vote against this absolute CPU time values.
> > ESX provides this values relative to a 20 second timeslots with 1 hour
> > of history. This makes it nearly impossible to obtain the absolute CPU
> > time. The same problem already exists for the domain's virtual CPU
> > time.
> >
> > When you look at virt-top's usage of the domain's virtual CPU time,
> > you see that it actually doesn't really care about the absolute value,
> > but deduces the CPU utilization from it. I suggest that we find a
> > different representation for this information that is not by
> > definition impossible to implement for ESX.
> >
> > Matthias
>
> I didn't know ESX couldn't return absolute CPU time value.
> Thank you for your comment.
>
> We really want to get CPU utilization information of the node, not
> absolute CPU time values.
> But linux doesn't provide CPU utilization directly,
> so my patch returns absolute CPU time values,
> and CPU utilization is calculated by client which uses new API.
>
> To return CPU utilization by new API, I think there are two issues of implementing on linux.
>
> a) How much interval does calculate CPU utilization?
> To calculate CPU utilization on linux, we need to get absolute CPU time value of the node
> from /proc/stat two times.
> How much interval properly? 1sec? 1min? or others?
The fact that there is the question of what is the right interval
demonstrates the inherant flaw in such an API design. Providing
the raw absolute time allows an app much more flexiblity in how
they work with the data, avoiding the need for such policies in
libvirt.
> b) Can new API wait its interval?
> If we select simply implementation, new API waits its interval.
> But API user don't want to wait every API calls, if its interval is long.
> So I think libvirtd will be calculating CPU utilization in background every interval.
> Is this approach OK?
IMHO we don't really want libvirtd to be constantly polling & calculating
this data, at least not unless an application is currently asking for it.
I think we want this API to have the style that is like the current
virDomainMemoryStats API. Then, we can define a set of parameters that
can be fetched, allowing each parameter to be optional
eg
enum {
VIR_NODE_CPU_TIME_KERNEL,
VIR_NODE_CPU_TIME_USER,
VIR_NODE_CPU_TIME_IDLE,
VIR_NODE_CPU_TIME_IOWAIT,
VIR_NODE_CPU_TIME_UTILIZATION,
};
For QEMU we'd provide the first 4 values, allowing apps maximum
flexibility in how they calculate utilization over different time
periods. For VMWare we'd provide only the last value.
An app like virt-manager, can display UTILIZATION value directly if
that is present, otherwise it will be able to calculate data from
the other times as it does now for domains. So it would work with
both QEMU and VMWare, to the best of its abilities.
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From matthias.bolte at googlemail.com Mon Apr 4 12:30:32 2011
From: matthias.bolte at googlemail.com (Matthias Bolte)
Date: Mon, 4 Apr 2011 14:30:32 +0200
Subject: [libvirt] [PATCH 1/6] virNodeGetCpuTime: Expose new API
In-Reply-To: <20110404115043.GA13616@redhat.com>
References: <20110401103833.8b66b57e.usui@mxm.nes.nec.co.jp>
<20110401105548.a78607f7.usui@mxm.nes.nec.co.jp>
<4D95FB08.20802@redhat.com>
<20110404110310.e85d09ba.usui@mxm.nes.nec.co.jp>
<20110404115043.GA13616@redhat.com>
Message-ID:
2011/4/4 Daniel P. Berrange :
> On Mon, Apr 04, 2011 at 11:03:10AM +0900, Minoru Usui wrote:
>> Hi, Matthias.
>>
>> On Fri, 1 Apr 2011 20:22:17 +0200
>> Matthias Bolte wrote:
>>
>> > 2011/4/1 Eric Blake :
>> > > On 03/31/2011 07:55 PM, Minoru Usui wrote:
>> > >> virNodeGetCpuTime: Expose new API
>> > >>
>> > >> ?include/libvirt/libvirt.h.in | ? 26 ++++++++++++++++++++++++++
>> > >> ?src/libvirt_public.syms ? ? ?| ? ?1 +
>> > >> ?2 files changed, 27 insertions(+), 0 deletions(-)
>> > >
>> > >>
>> > >> +/**
>> > >> + * virNodeCpuTime:
>> > >> + *
>> > >> + * a virNodeCpuTime is a structure filled by virNodeGetCpuTime() and providing
>> > >> + * the information for the cpu time of Node.
>> > >> + */
>> > >> +
>> > >> +typedef struct _virNodeCpuTime virNodeCpuTime;
>> > >> +
>> > >> +struct _virNodeCpuTime {
>> > >> + ? ?unsigned long long user;
>> > >> + ? ?unsigned long long system;
>> > >> + ? ?unsigned long long idle;
>> > >> + ? ?unsigned long long iowait;
>> > >> +};
>> > >
>> > > Can we portably get all of this information on Windows? ?If not, how do
>> > > you express which values we don't know how to obtain?
>> > >
>> >
>> > In the context of ESX I vote against this absolute CPU time values.
>> > ESX provides this values relative to a 20 second timeslots with 1 hour
>> > of history. This makes it nearly impossible to obtain the absolute CPU
>> > time. The same problem already exists for the domain's virtual CPU
>> > time.
>> >
>> > When you look at virt-top's usage of the domain's virtual CPU time,
>> > you see that it actually doesn't really care about the absolute value,
>> > but deduces the CPU utilization from it. I suggest that we find a
>> > different representation for this information that is not by
>> > definition impossible to implement for ESX.
>> >
>> > Matthias
>>
>> I didn't know ESX couldn't return absolute CPU time value.
>> Thank you for your comment.
>>
>> We really want to get CPU utilization information of the node, not
>> absolute CPU time values.
>> But linux doesn't provide CPU utilization directly,
>> so my patch returns absolute CPU time values,
>> and CPU utilization is calculated by client which uses new API.
>>
>> To return CPU utilization by new API, I think there are two issues of implementing on linux.
>>
>> ? a) How much interval does calculate CPU utilization?
>> ? ? ?To calculate CPU utilization on linux, we need to get absolute CPU time value of the node
>> ? ? ?from /proc/stat two times.
>> ? ? ?How much interval properly? 1sec? 1min? or others?
>
> The fact that there is the question of what is the right interval
> demonstrates the inherant flaw in such an API design. Providing
> the raw absolute time allows an app much more flexiblity in how
> they work with the data, avoiding the need for such policies in
> libvirt.
>
>> ? b) Can new API wait its interval?
>> ? ? ?If we select simply implementation, new API waits its interval.
>> ? ? ?But API user don't want to wait every API calls, if its interval is long.
>> ? ? ?So I think libvirtd will be calculating CPU utilization in background every interval.
>> ? ? ?Is this approach OK?
>
> IMHO we don't really want libvirtd to be constantly polling & calculating
> this data, at least not unless an application is currently asking for it.
> I think we want this API to have the style that is like the current
> virDomainMemoryStats ?API. Then, we can define a set of parameters that
> can be fetched, allowing each parameter to be optional
>
> eg
>
> ?enum {
> ? ? VIR_NODE_CPU_TIME_KERNEL,
> ? ? VIR_NODE_CPU_TIME_USER,
> ? ? VIR_NODE_CPU_TIME_IDLE,
> ? ? VIR_NODE_CPU_TIME_IOWAIT,
> ? ? VIR_NODE_CPU_TIME_UTILIZATION,
> ?};
>
> For QEMU we'd provide the first 4 values, allowing apps maximum
> flexibility in how they calculate utilization over different time
> periods. For VMWare we'd provide only the last value.
>
> An app like virt-manager, can display UTILIZATION value directly if
> that is present, otherwise it will be able to calculate data from
> the other times as it does now for domains. So it would work with
> both QEMU and VMWare, to the best of its abilities.
>
> Regards,
> Daniel
>
For ESX the driver doesn't even need to calculate a usage/utilization
value, because the ESX server already does this on it's own and the
driver can just ask for it. The usage value is in percent and 100%
represents all CPUs on the server.
I like that approach.
Matthias
From jclift at redhat.com Mon Apr 4 10:51:58 2011
From: jclift at redhat.com (Justin Clift)
Date: Mon, 4 Apr 2011 20:51:58 +1000
Subject: [libvirt] [Libvirt-announce] 0.9.0 freeze week,
RC2 version to test
In-Reply-To:
References: <20110328062538.GB7346@redhat.com>
<20110329144659.GD25888@redhat.com>
<20110331134423.GK24425@redhat.com>
<305053C1-65ED-4BCA-99CF-15927F4B31E9@redhat.com>
Message-ID: <883C8F48-51DF-4514-AC21-AA7397EE741A@redhat.com>
On 02/04/2011, at 6:34 PM, Matthias Bolte wrote:
>> Thanks. It's looking like some kind of problem interacting with
>> VirtualBox (v4.0.4):
>
>> This is the full gdb backtrace from the process:
>>
>> (gdb) thread apply all bt
>>
>> Thread 1 (process 85784):
>> #0 0x00007fff8549b3a6 in swtch_pri ()
>> #1 0x00007fff854d5b51 in _pthread_find_thread ()
> Strange point to get stuck.
>
> I assume VirtualBox for OSX comes with it's own GUI tool. Is it also
> affected or only virsh?
>
> Does this happen with VirtualBox 4.0.4 only, or is 4.x or even 3.x affected too?
Just tried with the earlier versions of 4.0.2 and 3.2.12, with full libvirt
autogen.sh and recompile after each installation. Exact same behaviour, hang
point, everything. :(
The VirtualBox GUI seems completely unaffected. While virsh is stuck, the
GUI can be started, VM's started/stopped, GUI shut down, all as per normal.
I guess this is going to take a bunch more debugging, which I personally don't
have the time for atm. (ugh) :(
Are there any other OSX users around that could take a look?
Regards and best wishes,
Justin Clift
From berrange at redhat.com Mon Apr 4 12:55:31 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 13:55:31 +0100
Subject: [libvirt] [PATCH] Allow handshake with child process during startup
Message-ID: <1301921731-32248-1-git-send-email-berrange@redhat.com>
Allow the parent process to perform a bi-directional handshake
with the child process during fork/exec. The child process
will fork and do its initial setup. Immediately prior to the
exec(), it will stop & wait for a handshake from the parent
process. The parent process will spawn the child and wait
until the child reaches the handshake point. It will do
whatever extra setup work is required, before signalling the
child to continue.
The implementation of this is done using two pairs of blocking
pipes. The first pair is used to block the parent, until the
child writes a single byte. Then the second pair pair is used
to block the child, until the parent confirms with another
single byte.
* src/util/command.c, src/util/command.h,
src/libvirt_private.syms: Add APIs to perform a handshake
---
src/libvirt_private.syms | 3 +
src/util/command.c | 142 +++++++++++++++++++++++++++++++++++++++++++++-
src/util/command.h | 5 ++
3 files changed, 148 insertions(+), 2 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 114bc2e..87f0432 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -106,11 +106,14 @@ virCommandAddEnvString;
virCommandClearCaps;
virCommandDaemonize;
virCommandFree;
+virCommandHandshakeNotify;
+virCommandHandshakeWait;
virCommandNew;
virCommandNewArgList;
virCommandNewArgs;
virCommandNonblockingFDs;
virCommandPreserveFD;
+virCommandRequireHandshake;
virCommandRun;
virCommandRunAsync;
virCommandSetErrorBuffer;
diff --git a/src/util/command.c b/src/util/command.c
index 2e475a0..d8440ca 100644
--- a/src/util/command.c
+++ b/src/util/command.c
@@ -35,6 +35,11 @@
#include "files.h"
#include "buf.h"
+#include
+#include
+#include
+#include
+
#define VIR_FROM_THIS VIR_FROM_NONE
#define virCommandError(code, ...) \
@@ -76,6 +81,10 @@ struct _virCommand {
int *outfdptr;
int *errfdptr;
+ bool handshake;
+ int handshakeWait[2];
+ int handshakeNotify[2];
+
virExecHook hook;
void *opaque;
@@ -107,6 +116,11 @@ virCommandNewArgs(const char *const*args)
if (VIR_ALLOC(cmd) < 0)
return NULL;
+ cmd->handshakeWait[0] = -1;
+ cmd->handshakeWait[1] = -1;
+ cmd->handshakeNotify[0] = -1;
+ cmd->handshakeNotify[1] = -1;
+
FD_ZERO(&cmd->preserve);
FD_ZERO(&cmd->transfer);
cmd->infd = cmd->outfd = cmd->errfd = -1;
@@ -1115,7 +1129,6 @@ virCommandRun(virCommandPtr cmd, int *exitstatus)
return ret;
}
-
/*
* Perform all virCommand-specific actions, along with the user hook.
*/
@@ -1125,12 +1138,61 @@ virCommandHook(void *data)
virCommandPtr cmd = data;
int res = 0;
- if (cmd->hook)
+ if (cmd->hook) {
+ VIR_DEBUG("Run hook %p %p", cmd->hook, cmd->opaque);
res = cmd->hook(cmd->opaque);
+ VIR_DEBUG("Done hook %d", res);
+ }
if (res == 0 && cmd->pwd) {
VIR_DEBUG("Running child in %s", cmd->pwd);
res = chdir(cmd->pwd);
+ if (res < 0) {
+ virReportSystemError(errno,
+ _("Unable to change to %s"), cmd->pwd);
+ }
+ }
+ if (cmd->handshake) {
+ char c = res < 0 ? '0' : '1';
+ int rv;
+ VIR_DEBUG("Notifying parent for handshake start on %d", cmd->handshakeWait[1]);
+ if (safewrite(cmd->handshakeWait[1], &c, sizeof(c)) != sizeof(c)) {
+ virReportSystemError(errno, "%s", _("Unable to notify parent process"));
+ return -1;
+ }
+
+ /* On failure we pass the error message back to parent,
+ * so they don't have to dig through stderr logs
+ */
+ if (res < 0) {
+ virErrorPtr err = virGetLastError();
+ const char *msg = err ? err->message :
+ _("Unknown failure during hook execution");
+ size_t len = strlen(msg) + 1;
+ if (safewrite(cmd->handshakeWait[1], msg, len) != len) {
+ virReportSystemError(errno, "%s", _("Unable to send error to parent process"));
+ return -1;
+ }
+ return -1;
+ }
+
+ VIR_DEBUG("Waiting on parent for handshake complete on %d", cmd->handshakeNotify[0]);
+ if ((rv = saferead(cmd->handshakeNotify[0], &c, sizeof(c))) != sizeof(c)) {
+ if (rv < 0)
+ virReportSystemError(errno, "%s", _("Unable to wait on parent process"));
+ else
+ virReportSystemError(EIO, "%s", _("libvirtd quit during handshake"));
+ return -1;
+ }
+ if (c != '1') {
+ virReportSystemError(EINVAL, _("Unexpected confirm code '%c' from parent process"), c);
+ return -1;
+ }
+ VIR_FORCE_CLOSE(cmd->handshakeWait[1]);
+ VIR_FORCE_CLOSE(cmd->handshakeNotify[0]);
}
+
+ VIR_DEBUG("Hook is done %d", res);
+
return res;
}
@@ -1220,6 +1282,10 @@ virCommandRunAsync(virCommandPtr cmd, pid_t *pid)
FD_CLR(i, &cmd->transfer);
}
}
+ if (cmd->handshake) {
+ VIR_FORCE_CLOSE(cmd->handshakeWait[1]);
+ VIR_FORCE_CLOSE(cmd->handshakeNotify[0]);
+ }
if (ret == 0 && pid)
*pid = cmd->pid;
@@ -1360,6 +1426,71 @@ virCommandAbort(virCommandPtr cmd ATTRIBUTE_UNUSED)
}
#endif
+
+void virCommandRequireHandshake(virCommandPtr cmd)
+{
+ if (pipe(cmd->handshakeWait) < 0) {
+ cmd->has_error = errno;
+ return;
+ }
+ if (pipe(cmd->handshakeNotify) < 0) {
+ VIR_FORCE_CLOSE(cmd->handshakeWait[0]);
+ VIR_FORCE_CLOSE(cmd->handshakeWait[1]);
+ cmd->has_error = errno;
+ return;
+ }
+
+ VIR_DEBUG("Transfer handshake wait=%d notify=%d",
+ cmd->handshakeWait[1], cmd->handshakeNotify[0]);
+ virCommandPreserveFD(cmd, cmd->handshakeWait[1]);
+ virCommandPreserveFD(cmd, cmd->handshakeNotify[0]);
+ cmd->handshake = true;
+}
+
+int virCommandHandshakeWait(virCommandPtr cmd)
+{
+ char c;
+ int rv;
+ VIR_DEBUG("Wait for handshake on %d", cmd->handshakeWait[0]);
+ if ((rv = saferead(cmd->handshakeWait[0], &c, sizeof(c))) != sizeof(c)) {
+ if (rv < 0)
+ virReportSystemError(errno, "%s", _("Unable to wait for child process"));
+ else
+ virReportSystemError(EIO, "%s", _("Child process quit during startup handshake"));
+ return -1;
+ }
+ if (c != '1') {
+ char *msg;
+ ssize_t len;
+ if (VIR_ALLOC_N(msg, 1024) < 0) {
+ virReportOOMError();
+ return -1;
+ }
+ if ((len = saferead(cmd->handshakeWait[0], msg, 1024)) < 0) {
+ VIR_FREE(msg);
+ virReportSystemError(errno, "%s", _("No error message from child failure"));
+ return -1;
+ }
+ msg[len-1] = '\0';
+ virCommandError(VIR_ERR_INTERNAL_ERROR, "%s", msg);
+ VIR_FREE(msg);
+ return -1;
+ }
+ return 0;
+}
+
+int virCommandHandshakeNotify(virCommandPtr cmd)
+{
+ char c = '1';
+ VIR_DEBUG("Notify handshake on %d", cmd->handshakeWait[0]);
+ if (safewrite(cmd->handshakeNotify[1], &c, sizeof(c)) != sizeof(c)) {
+ virReportSystemError(errno, "%s", _("Unable to notify child process"));
+ return -1;
+ }
+ return 0;
+}
+
+
/*
* Release all resources
*/
@@ -1391,6 +1522,13 @@ virCommandFree(virCommandPtr cmd)
VIR_FREE(cmd->pwd);
+ if (cmd->handshake) {
+ VIR_FORCE_CLOSE(cmd->handshakeWait[0]);
+ VIR_FORCE_CLOSE(cmd->handshakeWait[1]);
+ VIR_FORCE_CLOSE(cmd->handshakeNotify[0]);
+ VIR_FORCE_CLOSE(cmd->handshakeNotify[1]);
+ }
+
VIR_FREE(cmd->pidfile);
if (cmd->reap)
diff --git a/src/util/command.h b/src/util/command.h
index ff8ccf5..4712301 100644
--- a/src/util/command.h
+++ b/src/util/command.h
@@ -274,6 +274,11 @@ int virCommandRunAsync(virCommandPtr cmd,
int virCommandWait(virCommandPtr cmd,
int *exitstatus) ATTRIBUTE_RETURN_CHECK;
+void virCommandRequireHandshake(virCommandPtr cmd);
+
+int virCommandHandshakeWait(virCommandPtr cmd);
+int virCommandHandshakeNotify(virCommandPtr cmd);
+
/*
* Abort an async command if it is running, without issuing
* any errors or affecting errno. Designed for error paths
--
1.7.4
From stefanha at gmail.com Mon Apr 4 12:58:35 2011
From: stefanha at gmail.com (Stefan Hajnoczi)
Date: Mon, 4 Apr 2011 13:58:35 +0100
Subject: [libvirt] [Qemu-devel] [PATCH v2 3/3] raw-posix: Re-open host
CD-ROM after media change
In-Reply-To: <20110404104753.GX13616@redhat.com>
References: <1301425482-8722-1-git-send-email-stefanha@linux.vnet.ibm.com>
<1301425482-8722-4-git-send-email-stefanha@linux.vnet.ibm.com>
<20110404104753.GX13616@redhat.com>
Message-ID:
On Mon, Apr 4, 2011 at 11:47 AM, Daniel P. Berrange wrote:
> On Sun, Apr 03, 2011 at 07:06:17PM +0100, Stefan Hajnoczi wrote:
>> On Sun, Apr 3, 2011 at 2:12 PM, Blue Swirl wrote:
>> > On Sun, Apr 3, 2011 at 2:57 PM, Stefan Hajnoczi wrote:
>> >> On Tue, Mar 29, 2011 at 8:04 PM, Stefan Hajnoczi
>> >> wrote:
>> >>> Piggy-back on the guest CD-ROM polling to poll on the host. ?Open and
>> >>> close the host CD-ROM file descriptor to ensure we read the new size and
>> >>> not a stale size.
>> >>>
>> >>> Two things are going on here:
>> >>>
>> >>> 1. If hald/udisks is not already polling CD-ROMs on the host then
>> >>> ? re-opening the CD-ROM causes the host to read the new medium's size.
>> >>>
>> >>> 2. There is a bug in Linux which means the CD-ROM file descriptor must
>> >>> ? be re-opened in order for lseek(2) to see the new size. ?The
>> >>> ? inode size gets out of sync with the underlying device (which you can
>> >>> ? confirm by checking that /sys/block/sr0/size and lseek(2) do not
>> >>> ? match after media change). ?I have raised this with the
>> >>> ? maintainers but we need a workaround for the foreseeable future.
>> >>>
>> >>> Note that these changes are all in a #ifdef __linux__ section.
>> >>>
>> >>> Signed-off-by: Stefan Hajnoczi
>> >>> ---
>> >>> ?block/raw-posix.c | ? 26 ++++++++++++++++++++++----
>> >>> ?1 files changed, 22 insertions(+), 4 deletions(-)
>> >>>
>> >>> diff --git a/block/raw-posix.c b/block/raw-posix.c
>> >>> index 6b72470..8b5205c 100644
>> >>> --- a/block/raw-posix.c
>> >>> +++ b/block/raw-posix.c
>> >>> @@ -1238,10 +1238,28 @@ static int cdrom_is_inserted(BlockDriverState *bs)
>> >>> ? ? BDRVRawState *s = bs->opaque;
>> >>> ? ? int ret;
>> >>>
>> >>> - ? ?ret = ioctl(s->fd, CDROM_DRIVE_STATUS, CDSL_CURRENT);
>> >>> - ? ?if (ret == CDS_DISC_OK)
>> >>> - ? ? ? ?return 1;
>> >>> - ? ?return 0;
>> >>> + ? ?/*
>> >>> + ? ? * Close the file descriptor if no medium is present and open it to poll
>> >>> + ? ? * again. ?This ensures the medium size is refreshed. ?If the file
>> >>> + ? ? * descriptor is kept open the size can become stale. ?This is essentially
>> >>> + ? ? * replicating CD-ROM polling but is driven by the guest. ?As the guest
>> >>> + ? ? * polls, we poll the host.
>> >>> + ? ? */
>> >>> +
>> >>> + ? ?if (s->fd == -1) {
>> >>> + ? ? ? ?s->fd = qemu_open(bs->filename, s->open_flags, 0644);
>> >>> + ? ? ? ?if (s->fd < 0) {
>> >>> + ? ? ? ? ? ?return 0;
>> >>> + ? ? ? ?}
>> >>> + ? ?}
>> >>> +
>> >>> + ? ?ret = (ioctl(s->fd, CDROM_DRIVE_STATUS, CDSL_CURRENT) == CDS_DISC_OK);
>> >>> +
>> >>> + ? ?if (!ret) {
>> >>> + ? ? ? ?close(s->fd);
>> >>> + ? ? ? ?s->fd = -1;
>> >>> + ? ?}
>> >>> + ? ?return ret;
>> >>> ?}
>> >>>
>> >>> ?static int cdrom_eject(BlockDriverState *bs, int eject_flag)
>> >>> --
>> >>> 1.7.4.1
>> >>>
>> >>>
>> >>>
>> >>
>> >> There is an issue with reopening host devices in QEMU when running
>> >> under libvirt. ?It appears that libvirt chowns image files (including
>> >> device nodes) so that the launched QEMU process can access them.
>> >>
>> >> Unfortunately after media change on host devices udev will reset the
>> >> ownership of the device node. ?This causes open(2) to fail with EACCES
>> >> since the QEMU process does not have the right uid/gid/groups and
>> >> libvirt is unaware that the file's ownership has changed.
>> >>
>> >> In order for media change to work with Linux host CD-ROM it is
>> >> necessary to reopen the file (otherwise the inode size will not
>> >> refresh, this is an issue with existing kernels).
>> >>
>> >> How can libvirt's security model be made to support this case? ?In
>> >> theory udev could be temporarily configured with libvirt permissions
>> >> for the CD-ROM device while passed through to the guest, but is that
>> >> feasible?
>> >
>> > How about something like this: Add an explicit reopen method to
>> > BlockDriver. Make a special block device for passed file descriptors.
>> > Pass descriptors in libvirt for CD-ROMs instead of the device paths.
>> > The reopen method for file descriptors should notify libvirt about
>> > need to pass a reopened descriptor and then block all accesses until a
>> > new descriptor is available. This should also solve your earlier
>> > problem.
>>
>> I'm hoping libvirt's behavior can be made to just work rather than
>> adding new features to QEMU. ?But perhaps passing file descriptors is
>> useful for more than just reopening host devices. ?This would
>> basically be a privilege separation model where the QEMU process isn't
>> able to open files itself but can request libvirt to open them on its
>> behalf.
>
> It is rather frickin' annoying the way udev resets the ownership
> when the media merely changes. If it isn't possible to stop udev
> doing this, then i think the only practical thing is to use ACLs
> instead of user/group ownership. We wanted to switch to ACLs in
> libvirt for other reasons already, but it isn't quite as simple
> as it sounds[1] so we've not done it just yet.
>
> Daniel
>
> [1] Mostly due to handling upgrades from existing libvirtd while
> ? ?VMs are running, and coping with filesystems which don't
> ? ?support ACLs (or have them turned of by mount options)
I haven't peeked at how udev does it but perhaps the ACLs will be lost
or reset across media change too?
Daniel, do you know someone from the udev side who we should include
in this discussion?
Stefan
From aliguori at us.ibm.com Mon Apr 4 13:02:26 2011
From: aliguori at us.ibm.com (Anthony Liguori)
Date: Mon, 04 Apr 2011 08:02:26 -0500
Subject: [libvirt] [Qemu-devel] [PATCH v2 3/3] raw-posix: Re-open host
CD-ROM after media change
In-Reply-To: <20110404104753.GX13616@redhat.com>
References: <1301425482-8722-1-git-send-email-stefanha@linux.vnet.ibm.com>
<1301425482-8722-4-git-send-email-stefanha@linux.vnet.ibm.com>
<20110404104753.GX13616@redhat.com>
Message-ID: <4D99C162.7060706@us.ibm.com>
On 04/04/2011 05:47 AM, Daniel P. Berrange wrote:
>> I'm hoping libvirt's behavior can be made to just work rather than
>> adding new features to QEMU. But perhaps passing file descriptors is
>> useful for more than just reopening host devices. This would
>> basically be a privilege separation model where the QEMU process isn't
>> able to open files itself but can request libvirt to open them on its
>> behalf.
> It is rather frickin' annoying the way udev resets the ownership
> when the media merely changes. If it isn't possible to stop udev
> doing this, then i think the only practical thing is to use ACLs
> instead of user/group ownership. We wanted to switch to ACLs in
> libvirt for other reasons already, but it isn't quite as simple
> as it sounds[1] so we've not done it just yet.
Isn't the root of the problem that you're not running a guest in the
expected security context?
How much of a leap would it be to spawn a guest with the credentials of
the user that created/defined it? Or better yet, to let the user be
specified in the XML.
Regards,
Anthony Liguori
> Daniel
>
> [1] Mostly due to handling upgrades from existing libvirtd while
> VMs are running, and coping with filesystems which don't
> support ACLs (or have them turned of by mount options)
From berrange at redhat.com Mon Apr 4 13:16:39 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 14:16:39 +0100
Subject: [libvirt] [Qemu-devel] [PATCH v2 3/3] raw-posix: Re-open host
CD-ROM after media change
In-Reply-To: <4D99C162.7060706@us.ibm.com>
References: <1301425482-8722-1-git-send-email-stefanha@linux.vnet.ibm.com>
<1301425482-8722-4-git-send-email-stefanha@linux.vnet.ibm.com>
<20110404104753.GX13616@redhat.com> <4D99C162.7060706@us.ibm.com>
Message-ID: <20110404131639.GB13616@redhat.com>
On Mon, Apr 04, 2011 at 08:02:26AM -0500, Anthony Liguori wrote:
> On 04/04/2011 05:47 AM, Daniel P. Berrange wrote:
> >>I'm hoping libvirt's behavior can be made to just work rather than
> >>adding new features to QEMU. But perhaps passing file descriptors is
> >>useful for more than just reopening host devices. This would
> >>basically be a privilege separation model where the QEMU process isn't
> >>able to open files itself but can request libvirt to open them on its
> >>behalf.
> >It is rather frickin' annoying the way udev resets the ownership
> >when the media merely changes. If it isn't possible to stop udev
> >doing this, then i think the only practical thing is to use ACLs
> >instead of user/group ownership. We wanted to switch to ACLs in
> >libvirt for other reasons already, but it isn't quite as simple
> >as it sounds[1] so we've not done it just yet.
>
> Isn't the root of the problem that you're not running a guest in the
> expected security context?
That doesn't really have any impact. If a desktop user is logged
in, udev may change the ownership to match that user, but if they
aren't, then udev may reset it to root:disk. Either way, QEMU
may loose permissions to the disk.
> How much of a leap would it be to spawn a guest with the credentials
> of the user that created/defined it? Or better yet, to let the user
> be specified in the XML.
That's a completely independent RFE which won't fix this issue in
the general case.
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From jdenemar at redhat.com Mon Apr 4 13:18:59 2011
From: jdenemar at redhat.com (Jiri Denemark)
Date: Mon, 4 Apr 2011 15:18:59 +0200
Subject: [libvirt] [PATCH] qemu: Don't fail driver startup with ancient qemu
Message-ID: <2e1f2e4705bb467bcf237647706555bf4e97ec1e.1301923139.git.jdenemar@redhat.com>
Failure to extract version info (e.g., because qemu binary is so ancient
that it doesn't even support -help) shouldn't be considered fatal since
we only need it to detect whether qemu supports bootindex option.
---
src/qemu/qemu_capabilities.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index f86e7f5..6d2a3f6 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -554,9 +554,10 @@ qemuCapsInitGuest(virCapsPtr caps,
!virCapabilitiesAddGuestFeature(guest, "cpuselection", 1, 0))
goto error;
- if (qemuCapsExtractVersionInfo(binary, info->arch, NULL, &qemuCaps) < 0 ||
- (qemuCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX) &&
- !virCapabilitiesAddGuestFeature(guest, "deviceboot", 1, 0)))
+ if (qemuCapsExtractVersionInfo(binary, info->arch,
+ NULL, &qemuCaps) == 0 &&
+ qemuCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX) &&
+ !virCapabilitiesAddGuestFeature(guest, "deviceboot", 1, 0))
goto error;
if (hvm) {
--
1.7.4.1
From avi at redhat.com Mon Apr 4 13:22:38 2011
From: avi at redhat.com (Avi Kivity)
Date: Mon, 04 Apr 2011 16:22:38 +0300
Subject: [libvirt] [Qemu-devel] [PATCH v2 3/3] raw-posix: Re-open host
CD-ROM after media change
In-Reply-To:
References: <1301425482-8722-1-git-send-email-stefanha@linux.vnet.ibm.com> <1301425482-8722-4-git-send-email-stefanha@linux.vnet.ibm.com>
Message-ID: <4D99C61E.3080600@redhat.com>
On 04/03/2011 02:57 PM, Stefan Hajnoczi wrote:
> In order for media change to work with Linux host CD-ROM it is
> necessary to reopen the file (otherwise the inode size will not
> refresh, this is an issue with existing kernels).
>
Maybe we should fix the bug in Linux (and backport as necessary)?
I think cd-rom assignment is sufficiently obscure that we can require a
fixed kernel instead of providing a workaround.
--
error compiling committee.c: too many arguments to function
From berrange at redhat.com Mon Apr 4 13:23:59 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 14:23:59 +0100
Subject: [libvirt] [PATCH] qemu: Don't fail driver startup with ancient
qemu
In-Reply-To: <2e1f2e4705bb467bcf237647706555bf4e97ec1e.1301923139.git.jdenemar@redhat.com>
References: <2e1f2e4705bb467bcf237647706555bf4e97ec1e.1301923139.git.jdenemar@redhat.com>
Message-ID: <20110404132359.GC13616@redhat.com>
On Mon, Apr 04, 2011 at 03:18:59PM +0200, Jiri Denemark wrote:
> Failure to extract version info (e.g., because qemu binary is so ancient
> that it doesn't even support -help) shouldn't be considered fatal since
> we only need it to detect whether qemu supports bootindex option.
> ---
> src/qemu/qemu_capabilities.c | 7 ++++---
> 1 files changed, 4 insertions(+), 3 deletions(-)
What version QEMU doesn't support -help ?
We only aim to work with QEMU >= 0.9.0 and I'm fairly sure
that has -help support.
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From veillard at redhat.com Mon Apr 4 13:30:58 2011
From: veillard at redhat.com (Daniel Veillard)
Date: Mon, 4 Apr 2011 21:30:58 +0800
Subject: [libvirt] Release of libvirt-0.9.0
Message-ID: <20110404133058.GT24385@redhat.com>
As scheduled, libvirt 0.9.0 was tagged and pushed today, it's
available from FTP at:
ftp://libvirt.org/libvirt/
This is a large release w.r.t. the amount of features and changes,
and well worth bumping the middle version number. We are also getting
closer to a 1.0.0 release !
Features:
- Support cputune cpu usage tuning (Osier Yang and Nikunj A. Dadhania)
- Add public APIs for storage volume upload/download (Daniel P. Berrange)
- Add public API for setting migration speed on the fly (Daniel P. Berrange)
- Add libxenlight driver (Jim Fehlig and Markus Gro?)
- qemu: support migration to fd (Eric Blake)
- libvirt: add virDomain{Get,Set}BlkioParameters (Gui Jianfeng)
- setmem: introduce a new libvirt API (virDomainSetMemoryFlags) (Taku Izumi)
- Expose event loop implementation as a public API (Daniel P. Berrange)
- Dump the debug buffer to libvirtd.log on fatal signal (Daniel Veillard)
- Audit support (Eric Blake)
Documentation:
- fix typo (Eric Blake)
- correct invalid xml (Eric Blake)
- virsh: Fix documentation for memtune command (Jiri Denemark)
- Fix several formatting mistakes in doc (Michal Privoznik)
- mention C89 syntax preferences (Eric Blake)
- document recent hook additions (Eric Blake)
- Update on the goal page (Daniel Veillard)
- Document first release with spice and qxl (Cole Robinson)
- Add schema definition for imagelabel (Osier Yang)
- update virGetVersion description (Tiziano Mueller)
- Improve logging documentation including the debug buffer (Daniel Veillard)
- update windows page for initial libvirt 0.8.8 installer (Justin Clift)
- formatdomain.html.in: Fix spelling PIC->PCI (Philipp Hahn)
- fix missing
(Eric Blake)
- documenting the 802.1Qbg parameters of a 'direct' interface (Gerhard Stenzel)
- silence warnings about generated API docs (Eric Blake)
- document for interfaces (Eric Blake)
- correct range of default NAT subnet (Eric Blake)
- formatdomain: Add release info for disk attributes (Cole Robinson)
- Fix spelling mistake: seek (Philipp Hahn)
- maint: fix grammar in error message (Eric Blake)
Portability:
- virsh: fix mingw failure on creating nonblocking pipe (Eric Blake)
- Remove iohelper on Win32 since it is not required (Daniel P. Berrange)
- Fix domain events C example on Win32 (Daniel P. Berrange)
- build: fix compilation on mingw (Eric Blake)
- util: use SCM_RIGHTS in virFileOperation when needed (Eric Blake)
- Don't use INT64_MAX in libvirt.h because it requires stdint.h (Matthias Bolte)
- libvirtd: Remove indirect linking (Guido G?nther)
- build: avoid compiler warning on cygwin (Eric Blake)
- build: fix build on cygwin (Eric Blake)
- build: fix building error when building without libvirtd (Wen Congyang)
- virsh: Remove indirect link against libxml2 (Guido G?nther)
- Fix build on cygwin (Daniel Veillard)
- Add check for kill() to fix build of cgroups on win32 (Daniel P. Berrange)
- build: fix broken mingw cross-compilation (Eric Blake)
Bug fixes:
- fix memory leak in qemuProcessHandleGraphics() (Wen Congyang)
- do not lock vm while allocating memory (Wen Congyang)
- Fix libxl driver startup (Daniel Veillard)
- qemu: Ignore libvirt debug messages in qemu log (Jiri Denemark)
- qemu: Fix improper logic of qemuCgroupSetup (Osier Yang)
- free tmp after unlinking it (Wen Congyang)
- qemu: Fix media eject with qemu-0.12.* (Jiri Denemark)
- check whether qemuMonitorJSONHMP() failed (Wen Congyang)
- do not send monitor command after monitor meet error (Wen Congyang)
- qemu: unlock qemu driver before return from domain save (Hu Tao)
- qemu: fix regression with fd labeling on migration (Eric Blake)
- Ignore return value of virDomainObjUnref (Markus Gro?)
- Fix infinite loop in daemon if client quits with multiple streams open (Daniel P. Berrange)
- qemu: fix regression that hangs on save failure (Eric Blake)
- qemu: fix restoring a compressed save image (Eric Blake)
- util: allow clearing cloexec bit (Eric Blake)
- logging: always NUL-terminate circular buffer (Eric Blake)
- tests: don't alter state in $HOME (Eric Blake)
- qemu: don't restore state label twice (Eric Blake)
- Fix syntax error in configure.ac (Osier Yang)
- remote: Don't leak gnutls session on negotiation error (Matthias Bolte)
- hooks: fix regression in previous patch (Eric Blake)
- Add missing { for qemudDomainInterfaceStats (Philipp Hahn)
- daemon: Avoid resetting errors before they are reported (Jiri Denemark)
- fix the check of the output of monitor command 'device_add' (Wen Congyang)
- Make error reporting in libvirtd thread safe (Jiri Denemark)
- update domain status forcibly even if attach a device failed (Wen Congyang)
- util: Fix return value for virJSONValueFromString if it fails (Osier Yang)
- Initialization error of qemuCgroupData in Qemu host usb hotplug (Wen Congyang)
- build: fix missing initializer (Eric Blake)
- Fix uninitialized variable & error reporting in LXC veth setup (Daniel P. Berrange)
- udev: fix regression with qemu:///session (Eric Blake)
- logging: fix off-by-one bug (Eric Blake)
- do not report OOM error when prepareCall() failed (Wen Congyang)
- Don't return an error on failure to create blkio controller (Hu Tao)
- qemu: respect locking rules (Eric Blake)
- openvz: fix a simple bug in openvzListDefinedDomains() (Jean-Baptiste Rouault)
- Fix delayed event delivery when SASL is active (Daniel P. Berrange)
- qemu: Fix copy&paste error messages in text monitor (Jiri Denemark)
- do not unref obj in qemuDomainObjExitMonitor* (Wen Congyang)
- qemu: check driver name while attaching disk (Wen Congyang)
- remote: Add missing virCondDestroy calls (Matthias Bolte)
- build: improve rpm generation for distro backports (Eric Blake)
- storage: Fix a problem which will cause libvirtd crashed (Osier Yang)
- Fix misc bugs in virCommandPtr (Daniel P. Berrange)
- libvirt: fix a simple bug in virDomainSetMemoryFlags() (Taku Izumi)
- qemu: Check the unsigned integer overflow (Osier Yang)
- audit: eliminate potential null pointer deref when auditing macvtap devices (Laine Stump)
- network driver: don't send default route to clients on isolated networks (Laine Stump)
- virsh: Free stream when shutdown console (Osier Yang)
- Add missing checks for read only connections (Guido G?nther)
- qemu: fix -global argument usage (Eric Blake)
- Make sure we reset the umask on the error path (Guido G?nther)
- qemu: Stop guest CPUs before creating a snapshot (Jiri Denemark)
- qemu: Escape snapshot name passed to {save,load,del}vm (Jiri Denemark)
- qemu: Fix warnings in event handlers (Jiri Denemark)
- storage: Update qemu-img flag checking (Osier Yang)
- Make sure the rundir is accessible by the user (Guido G?nther)
- Fix a wrong error message thrown to user (Hu Tao)
- unlock eventLoop before calling callback function (Wen Congyang)
- fixes for several memory leaks (Phil Petty)
- Fix a counter bug in the log buffer (Daniel Veillard)
- qemu: avoid corruption of domain hashtable and misuse of freed domains (Laine Stump)
- qemu: Add missing lock of virDomainObj before calling virDomainUnref (Laine Stump)
- esx: Escape password for XML (Matthias Bolte)
- util: correct retry path in virFileOperation (Eric Blake)
- util: Allow removing hash entries in virHashForEach (Jiri Denemark)
- qemu: avoid double close on domain restore (Eric Blake)
- Fix port value parsing for serial and parallel ports (Michal Novotny)
- Fix off-by-1 in virFileAbsPath. (Daniel P. Berrange)
- security: avoid memory leak (Eric Blake)
- protect the scsi controller to be deleted when it is in use (Wen Congyang)
- virsh: freecell --all getting wrong NUMA nodes count (Michal Privoznik)
- remove duplicated call to reportOOMError (Christophe Fergeau)
Improvements:
- Make check_fc_host() and check_vport_capable() usable as rvalues (Guido G?nther)
- maint: avoid locale-sensitivity in string case comparisons (Eric Blake)
- extend logging to record configuration-related changes (Naoya Horiguchi)
- Add libvirt_iohelper to spec file (Daniel Veillard)
- cputune: New tests for cputune XML (Osier Yang)
- cputune: Support cputune for xend driver (Osier Yang)
- cputune: Support cputune for lxc driver (Osier Yang)
- cputune: Support cputune for qemu driver (Osier Yang)
- cputune: Implementations of parsing and formating cputune xml (Osier Yang)
- cputune: Add data structures presenting cputune XML (Osier Yang)
- cputune: Add document for cputune XML (Osier Yang)
- cputune: Add XML schema for cputune xml (Osier Yang)
- qemu: improve error message on failed fd transfer (Eric Blake)
- maint: ignore new built file (Eric Blake)
- Add domainSuspend/Resume to libxl driver (Markus Gro?)
- Add domainGetOSType to libxl driver (Markus Gro?)
- Add domainGetSchedulerType to libxl driver (Markus Gro?)
- Implements domainXMLTo/FromNative in libxl driver (Markus Gro?)
- Add vcpu functions to libxl driver (Markus Gro?)
- List authors in copyright headers (Markus Gro?)
- Add event callbacks to libxl driver (Markus Gro?)
- Remote protocol support for storage vol upload/download APIs (Daniel P. Berrange)
- Support volume data upload/download APIs in storage driver (Daniel P. Berrange)
- Add vol-upload and vol-download commands to virsh (Daniel P. Berrange)
- Enhance the streams helper to support plain file I/O (Daniel P. Berrange)
- Update event loop example programs to demonstrate best practice (Daniel P. Berrange)
- qemu: support fd: migration with compression (Eric Blake)
- qemu: skip granting access during fd migration (Eric Blake)
- qemu: consolidate migration to file code (Eric Blake)
- qemu: use common API for reading difficult files (Eric Blake)
- qemu, storage: improve type safety (Eric Blake)
- util: adjust indentation in previous patch (Eric Blake)
- util: rename virFileOperation to virFileOpenAs (Eric Blake)
- storage: simplify fd handling (Eric Blake)
- qemu: simplify domain save fd handling (Eric Blake)
- qemu: allow simple domain save to use fd: protocol (Eric Blake)
- Update of localisations, switch to transifex (Daniel Veillard)
- build: shorten libxenlight summary for consistent alignment (Eric Blake)
- command: add virCommandAbort for cleanup paths (Eric Blake)
- command: don't mix RunAsync and daemons (Eric Blake)
- command: properly diagnose process exit via signal (Eric Blake)
- Add memory functions to libxl driver (Markus Gro?)
- build: enforce reference count checking (Eric Blake)
- maint: prohibit access(,X_OK) (Eric Blake)
- Get cpu time and current memory balloon from libxl (Markus Gro?)
- build: nuke all .x-sc* files, and fix VPATH syntax-check (Eric Blake)
- command: reject pidfile on non-daemon (Eric Blake)
- rpm: add missing dependencies (Eric Blake)
- rpm: separate runtime and build requirements (Eric Blake)
- qemu: simplify monitor callbacks (Eric Blake)
- 8021Qbh: use preassociate-rr during the migration prepare stage (Roopa Prabhu)
- Wire up virDomainMigrateSetSpeed into QEMU driver (Daniel P. Berrange)
- Wire up virDomainMigrateSetSpeed for the remote RPC driver (Daniel P. Berrange)
- maint: update authors (Eric Blake)
- Disable libxl build in RPM on Fedora < 16 (Daniel P. Berrange)
- qemu: fallback to HMP drive_add/drive_del (Hu Tao)
- qemu: Only use HMP passthrough if it is supported (Jiri Denemark)
- qemu: Detect support for HMP passthrough (Jiri Denemark)
- qemu: add two hook script events "prepare" and "release" (Thibault Vincent)
- qemu: simplify interface fd handling in monitor (Eric Blake)
- qemu: simplify PCI configfd handling in monitor (Eric Blake)
- qemu: simplify monitor fd error handling (Eric Blake)
- util: guarantee sane errno in virFileIsExecutable (Eric Blake)
- Don't build libxenlight driver for Xen 4.0 (Jim Fehlig)
- network driver: log error and abort network startup when radvd isn't found (Laine Stump)
- build: translate changes in previous patch (Eric Blake)
- Ensure binary is resolved wrt $PATH in virExec (Daniel P. Berrange)
- util: Forbid calling hash APIs from iterator callback (Jiri Denemark)
- Avoid taking lock in libvirt debug dump (Daniel Veillard)
- unlock the monitor when unwatching the monitor (Wen Congyang)
- Add vim configuration that makes vim auto-indent code (Hu Tao)
- virsh: fix memtune's help message for swap_hard_limit (Nikunj A. Dadhania)
- Add PCI sysfs reset access (Alex Williamson)
- Support Xen sysctl v8, domctl v7 (Jim Fehlig)
- macvtap: log an error if on failure to connect to netlink socket (Laine Stump)
- qemu: improve efficiency of dd during snapshots (Eric Blake)
- virsh: allow empty string arguments (Eric Blake)
- qemu: Fallback to HMP when cpu_set QMP command is not found (Wen Congyang)
- Change message for VIR_FROM_RPC error domain (Daniel P. Berrange)
- Add compat function for geteuid() (Daniel P. Berrange)
- Add virSetBlocking() to allow O_NONBLOCK to be toggle on or off (Daniel P. Berrange)
- qemu: use more appropriate error (Eric Blake)
- Make LXC container startup/shutdown/I/O more robust (Daniel P. Berrange)
- Allow to dynamically set the size of the debug buffer (Daniel Veillard)
- qemu: consolidate duplicated monitor migration code (Eric Blake)
- qemu: use lighter-weight fd:n on incoming tunneled migration (Eric Blake)
- Fix performance problem of virStorageVolCreateXMLFrom() (Minoru Usui)
- libvirt-guests: avoid globbing when splitting $URIS (Eric Blake)
- libvirt-guest.init: quoting variables (Philipp Hahn)
- virsh: Insert error messages to avoid a quiet abortion of commands (Michal Privoznik)
- python: Use hardcoded python path in libvirt.py (Jiri Denemark)
- virsh: Allow starting domains by UUID (Jiri Denemark)
- network driver: Use a separate dhcp leases file for each network (Laine Stump)
- network driver: Start dnsmasq even if no dhcp ranges/hosts are specified. (Laine Stump)
- libvirt-guest.init: handle domain name with spaces (Philipp Hahn)
- domain.rng vs. formatdomain.html#elementsUSB (Philipp Hahn)
- Ignore backing file errors in FS storage pool (Philipp Hahn)
- remote-protocol: implement new BlkioParameters API (Gui Jianfeng)
- virsh: Adding blkiotune command to virsh tool (Gui Jianfeng)
- qemu: implement new BlkioParameters API (Gui Jianfeng)
- libvirt: implements virDomain{Get,Set}BlkioParameters (Gui Jianfeng)
- setmem: add the new options to "virsh setmem" command (Taku Izumi)
- setmem: implement the remote protocol to address the new API (Taku Izumi)
- setmem: implement the code to address the new API in the qemu driver (Taku Izumi)
- audit: audit use of /dev/net/tun, /dev/tapN, /dev/vhost-net (Eric Blake)
- qemu: don't request cgroup ACL access for /dev/net/tun (Eric Blake)
- qemu: support vhost in attach-interface (Eric Blake)
- qemu: Refactor qemuDomainSnapshotCreateXML (Jiri Denemark)
- qemu: Fallback to HMP for snapshot commands (Jiri Denemark)
- qemu: Setup infrastructure for HMP passthrough (Jiri Denemark)
- qemu: Replace deprecated option of qemu-img (Osier Yang)
- audit: also audit cgroup ACL permissions (Eric Blake)
- cgroup: allow fine-tuning of device ACL permissions (Eric Blake)
- audit: rename remaining qemu audit functions (Eric Blake)
- audit: also audit cgroup controller path (Eric Blake)
- audit: split cgroup audit types to allow more information (Eric Blake)
- audit: tweak audit messages to match conventions (Eric Blake)
- Don't overwrite virRun error messages (Cole Robinson)
- virsh: Change option parsing functions to return tri-state information (Michal Privoznik)
- virsh: change vshCommandOptString return type and fix const-correctness (Michal Privoznik)
- support to detach USB disk (Wen Congyang)
- rename qemuDomainDetachSCSIDiskDevice to qemuDomainDetachDiskDevice (Wen Congyang)
- qemu_hotplug: Reword error if spice password change not available (Cole Robinson)
- Move event code out of the daemon/ into src/util/ (Daniel P. Berrange)
- Convert daemon/virsh over to use primary event APIs, rather than impl (Daniel P. Berrange)
- Cleaning up some of the logging code (Daniel Veillard)
- qemu: Support vram for video of qxl type (Osier Yang)
- Add an an internal API for emergency dump of debug buffer (Daniel Veillard)
- Add logrotate support for libvirtd.log (Daniel Veillard)
- Change default log policy to libvirtd.log instead of syslog (Daniel Veillard)
- Force all logs to go to the round robbin memory buffer (Daniel Veillard)
- AUTHORS: adjust to preferred spelling (KAMEZAWA Hiroyuki)
- Pass virSecurityManagerPtr to virSecurityDAC{Set, Restore}ChardevCallback (Soren Hansen)
- maint: update to latest gnulib (Eric Blake)
- Attempt to improve an error message (Daniel P. Berrange)
- add additional event debug points (Daniel P. Berrange)
- qemu: only request sound cgroup ACL when required (Eric Blake)
- Add support for multiple serial ports into the Xen driver (Michal Novotny)
- Add APIs for killing off processes inside a cgroup (Daniel P. Berrange)
- Allow hash tables to use generic pointers as keys (Daniel P. Berrange)
- Remove deallocator parameter from hash functions (Daniel P. Berrange)
- Make commandtest more robust wrt its execution environment (Daniel P. Berrange)
- audit: audit qemu pci and usb device passthrough (Eric Blake)
- audit: audit qemu memory and vcpu adjusments (Eric Blake)
- audit: add qemu hooks for auditing cgroup events (Eric Blake)
- audit: prepare qemu for listing vm in cgroup audits (Eric Blake)
- cgroup: determine when skipping non-devices (Eric Blake)
- virExec: avoid uninitialized memory usage (Eric Blake)
- Allow 32-on-64 execution for LXC guests (Daniel P. Berrange)
- Put into internal.h so it is available everywhere (Daniel P. Berrange)
- qemu: Switch over command line capabilities to virBitmap (Jiri Denemark)
- qemu: Rename qemud\?CmdFlags to qemuCaps (Jiri Denemark)
- qemu: Use helper functions for handling cmd line capabilities (Jiri Denemark)
- qemu: Rename QEMUD_CMD_FLAG_* to QEMU_CAPS_* (Jiri Denemark)
- util: Add API for converting virBitmap into printable string (Jiri Denemark)
- util: Use unsigned long as a base type for virBitmap (Jiri Denemark)
- Expose name + UUID to LXC containers via env variables (Daniel P. Berrange)
- Fix discard of expected errors (Daniel P. Berrange)
- Fix group/mode for /dev/pts inside LXC container (Daniel P. Berrange)
- 802.1Qbh: Delay IFF_UP'ing interface until migration final stage (Roopa Prabhu)
- storage: make debug log more useful (Osier Yang)
- virsh: replace vshPrint with vshPrintExtra for snapshot list Otherwise extra information will be printed even if "--quiet" is specified. (Osier Yang)
- check device-mapper when building with mpath or disk storage driver (Wen Congyang)
- build: add dependency on gnutls-utils (Eric Blake)
- Renamed functions in xenxs (Markus Gro?)
- Moved XM formatting functions to xenxs (Markus Gro?)
- Moved XM parsing functions to xenxs (Markus Gro?)
- Moved SEXPR formatting functions to xenxs (Markus Gro?)
- Moved SEXPR parsing functions to xenxs (Markus Gro?)
- Moved some SEXPR functions from xen-unified (Markus Gro?)
- Moved SEXPR unit to utils (Markus Gro?)
- virt-*-validate.in: quote all variable references (Dan Kenigsberg)
- virt-pki-validate: behave when CERTTOOL is missing (Dan Kenigsberg)
- autobuild.sh: use VPATH build (Eric Blake)
- maint: fix 'make dist' in VPATH build (Eric Blake)
- build: don't require pod2man for tarball builds (Eric Blake)
- hash: make virHashFree more free-like (Eric Blake)
- build: Fix API docs generation in VPATH build (Jiri Denemark)
- Remove all object hashtable caches from virConnectPtr (Daniel P. Berrange)
- nwfilter: enable rejection of packets (Stefan Berger)
- Drop empty argument from dnsmasq call (Guido G?nther)
- esx: Ignore malformed host UUID from BIOS (Matthias Bolte)
- build: speed up non-maintainer builds (Eric Blake)
- build: recompute symbols after changing configure options (Eric Blake)
- Requires gettext for client package (Osier Yang)
- Do not add drive 'boot=on' param when a kernel is specified (Jim Fehlig)
- factor common code in virHashAddEntry and virHashUpdateEntry (Christophe Fergeau)
- add hash table rebalancing in virHashUpdateEntry (Christophe Fergeau)
- hash: modernize debug code (Eric Blake)
- build: improve 'make install' for VPATH builds (Eric Blake)
- check more error info about whether drive_add failed (Wen Congyang)
- logging: make VIR_ERROR and friends preserve errno (Eric Blake)
- maint: avoid 'make syntax-check' from tarball (Eric Blake)
- Give each virtual network bridge its own fixed MAC address (Laine Stump)
- Allow brAddTap to create a tap device that is down (Laine Stump)
- Add txmode attribute to interface XML for virtio backend (Laine Stump)
- Restructure domain struct interface "driver" data for easier expansion (Laine Stump)
- build: Fix VPATH build (Jiri Denemark)
- storage: Allow to delete device mapper disk partition (Osier Yang)
Cleanups:
- The next release is 0.9.0 not 0.8.9 (Daniel Veillard)
- maint: use space, not tab, in remote_protocol-structs (Eric Blake)
- Remove the Open Nebula driver (Daniel P. Berrange)
- domain_conf: drop unused ref-count in snapshot object (Eric Blake)
- Update the set of maintainers for the project (Daniel Veillard)
- Make virDomainObjParseNode() static (Hu Tao)
- maint: make spacing in .sh files easier (Eric Blake)
- network driver: Fix indentation from previous commit (Laine Stump)
- qemu: Rename qemuMonitorCommandWithHandler as qemuMonitorText* (Jiri Denemark)
- qemu: Rename qemuMonitorCommand{,WithFd} as qemuMonitorHMP* (Jiri Denemark)
- maint: avoid long lines in more tests (Eric Blake)
- maint: kill all remaining uses of old DEBUG macro (Eric Blake)
- maint: Expand tabs in python code (Jiri Denemark)
- remove space between function name and ( (Christophe Fergeau)
- don't check for NULL before calling virHashFree (Christophe Fergeau)
- remove no longer needed calls to virReportOOMError (Christophe Fergeau)
- Move all the QEMU migration code to a new file (Daniel P. Berrange)
- Split all QEMU process mangement code into separate file (Daniel P. Berrange)
Thanks to everybody who helped one way or another for this release !
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel at veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
From jdenemar at redhat.com Mon Apr 4 13:37:32 2011
From: jdenemar at redhat.com (Jiri Denemark)
Date: Mon, 4 Apr 2011 15:37:32 +0200
Subject: [libvirt] [PATCH] qemu: Don't fail driver startup with ancient
qemu
In-Reply-To: <20110404132359.GC13616@redhat.com>
References: <2e1f2e4705bb467bcf237647706555bf4e97ec1e.1301923139.git.jdenemar@redhat.com>
<20110404132359.GC13616@redhat.com>
Message-ID: <20110404133732.GH389283@orkuz.home>
On Mon, Apr 04, 2011 at 14:23:59 +0100, Daniel P. Berrange wrote:
> On Mon, Apr 04, 2011 at 03:18:59PM +0200, Jiri Denemark wrote:
> > Failure to extract version info (e.g., because qemu binary is so ancient
> > that it doesn't even support -help) shouldn't be considered fatal since
> > we only need it to detect whether qemu supports bootindex option.
> > ---
> > src/qemu/qemu_capabilities.c | 7 ++++---
> > 1 files changed, 4 insertions(+), 3 deletions(-)
>
> What version QEMU doesn't support -help ?
>
> We only aim to work with QEMU >= 0.9.0 and I'm fairly sure
> that has -help support.
An ancient one, 0.6.0. But that was just an example. Extracting version info
may fail for a bunch of reasons. The main thing is that it shouldn't fail qemu
driver startup since that results in libvirtd startup failure.
Jirka
From anthony at codemonkey.ws Mon Apr 4 13:38:53 2011
From: anthony at codemonkey.ws (Anthony Liguori)
Date: Mon, 04 Apr 2011 08:38:53 -0500
Subject: [libvirt] [Qemu-devel] [PATCH v2 3/3] raw-posix: Re-open host
CD-ROM after media change
In-Reply-To: <4D99C61E.3080600@redhat.com>
References: <1301425482-8722-1-git-send-email-stefanha@linux.vnet.ibm.com> <1301425482-8722-4-git-send-email-stefanha@linux.vnet.ibm.com>
<4D99C61E.3080600@redhat.com>
Message-ID: <4D99C9ED.3020602@codemonkey.ws>
On 04/04/2011 08:22 AM, Avi Kivity wrote:
> On 04/03/2011 02:57 PM, Stefan Hajnoczi wrote:
>> In order for media change to work with Linux host CD-ROM it is
>> necessary to reopen the file (otherwise the inode size will not
>> refresh, this is an issue with existing kernels).
>>
>
> Maybe we should fix the bug in Linux (and backport as necessary)?
>
> I think cd-rom assignment is sufficiently obscure that we can require
> a fixed kernel instead of providing a workaround.
Do reads fail after CD change? Or do they succeed and the size is just
reported incorrectly?
If it's the later, I'd agree that it needs fixing in the kernel. If
it's the former, I'd say it's clearly a feature.
Regards,
Anthony Liguori
From jdenemar at redhat.com Mon Apr 4 13:46:31 2011
From: jdenemar at redhat.com (Jiri Denemark)
Date: Mon, 4 Apr 2011 15:46:31 +0200
Subject: [libvirt] [PATCH] qemu: Rewrite LOOKUP_PTYS macro into a function
Message-ID: <6583e184fb3f616c15ec4bc42f1af58fff320a8b.1301924390.git.jdenemar@redhat.com>
The macro is huge and gives us nothing but headache when maintaining it.
---
The reason for this patch is not that I'm going to modify anything in
the code. It's that I was working in the area and noticed this huge
macro.
src/qemu/qemu_process.c | 102 ++++++++++++++++++++++++++++-------------------
1 files changed, 61 insertions(+), 41 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 90fcea0..53a42a5 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -895,51 +895,71 @@ qemuProcessExtractTTYPath(const char *haystack,
}
static int
+qemuProcessLookupPTYs(virDomainChrDefPtr *devices,
+ int count,
+ const char *prefix,
+ virHashTablePtr paths)
+{
+ int i;
+
+ for (i = 0 ; i < count ; i++) {
+ virDomainChrDefPtr chr = devices[i];
+ if (chr->source.type == VIR_DOMAIN_CHR_TYPE_PTY) {
+ char id[16];
+ const char *path;
+
+ if (snprintf(id, sizeof(id), "%s%d", prefix, i) >= sizeof(id))
+ return -1;
+
+ path = (const char *) virHashLookup(paths, id);
+ if (path == NULL) {
+ if (chr->source.data.file.path == NULL) {
+ /* neither the log output nor 'info chardev' had a
+ * pty path for this chardev, report an error
+ */
+ qemuReportError(VIR_ERR_INTERNAL_ERROR,
+ _("no assigned pty for device %s"), id);
+ return -1;
+ } else {
+ /* 'info chardev' had no pty path for this chardev,
+ * but the log output had, so we're fine
+ */
+ continue;
+ }
+ }
+
+ VIR_FREE(chr->source.data.file.path);
+ chr->source.data.file.path = strdup(path);
+
+ if (chr->source.data.file.path == NULL) {
+ virReportOOMError();
+ return -1;
+ }
+ }
+ }
+
+ return 0;
+}
+
+static int
qemuProcessFindCharDevicePTYsMonitor(virDomainObjPtr vm,
virHashTablePtr paths)
{
- int i;
+ if (qemuProcessLookupPTYs(vm->def->serials, vm->def->nserials,
+ "serial", paths) < 0)
+ return -1;
+
+ if (qemuProcessLookupPTYs(vm->def->parallels, vm->def->nparallels,
+ "parallel", paths) < 0)
+ return -1;
-#define LOOKUP_PTYS(array, arraylen, idprefix) \
- for (i = 0 ; i < (arraylen) ; i++) { \
- virDomainChrDefPtr chr = (array)[i]; \
- if (chr->source.type == VIR_DOMAIN_CHR_TYPE_PTY) { \
- char id[16]; \
- \
- if (snprintf(id, sizeof(id), idprefix "%i", i) >= sizeof(id)) \
- return -1; \
- \
- const char *path = (const char *) virHashLookup(paths, id); \
- if (path == NULL) { \
- if (chr->source.data.file.path == NULL) { \
- /* neither the log output nor 'info chardev' had a */ \
- /* pty path for this chardev, report an error */ \
- qemuReportError(VIR_ERR_INTERNAL_ERROR, \
- _("no assigned pty for device %s"), id); \
- return -1; \
- } else { \
- /* 'info chardev' had no pty path for this chardev, */\
- /* but the log output had, so we're fine */ \
- continue; \
- } \
- } \
- \
- VIR_FREE(chr->source.data.file.path); \
- chr->source.data.file.path = strdup(path); \
- \
- if (chr->source.data.file.path == NULL) { \
- virReportOOMError(); \
- return -1; \
- } \
- } \
- }
-
- LOOKUP_PTYS(vm->def->serials, vm->def->nserials, "serial");
- LOOKUP_PTYS(vm->def->parallels, vm->def->nparallels, "parallel");
- LOOKUP_PTYS(vm->def->channels, vm->def->nchannels, "channel");
- if (vm->def->console)
- LOOKUP_PTYS(&vm->def->console, 1, "console");
-#undef LOOKUP_PTYS
+ if (qemuProcessLookupPTYs(vm->def->channels, vm->def->nchannels,
+ "channel", paths) < 0)
+ return -1;
+
+ if (vm->def->console &&
+ qemuProcessLookupPTYs(&vm->def->console, 1, "console", paths) < 0)
+ return -1;
return 0;
}
--
1.7.4.1
From avi at redhat.com Mon Apr 4 13:49:40 2011
From: avi at redhat.com (Avi Kivity)
Date: Mon, 04 Apr 2011 16:49:40 +0300
Subject: [libvirt] [Qemu-devel] [PATCH v2 3/3] raw-posix: Re-open host
CD-ROM after media change
In-Reply-To: <4D99C9ED.3020602@codemonkey.ws>
References: <1301425482-8722-1-git-send-email-stefanha@linux.vnet.ibm.com> <1301425482-8722-4-git-send-email-stefanha@linux.vnet.ibm.com>
<4D99C61E.3080600@redhat.com> <4D99C9ED.3020602@codemonkey.ws>
Message-ID: <4D99CC74.9070703@redhat.com>
On 04/04/2011 04:38 PM, Anthony Liguori wrote:
> On 04/04/2011 08:22 AM, Avi Kivity wrote:
>> On 04/03/2011 02:57 PM, Stefan Hajnoczi wrote:
>>> In order for media change to work with Linux host CD-ROM it is
>>> necessary to reopen the file (otherwise the inode size will not
>>> refresh, this is an issue with existing kernels).
>>>
>>
>> Maybe we should fix the bug in Linux (and backport as necessary)?
>>
>> I think cd-rom assignment is sufficiently obscure that we can require
>> a fixed kernel instead of providing a workaround.
>
> Do reads fail after CD change? Or do they succeed and the size is
> just reported incorrectly?
>
> If it's the later, I'd agree that it needs fixing in the kernel. If
> it's the former, I'd say it's clearly a feature.
>
Even if it's a documented or intentional feature, we can add an ioctl to
"refresh" the device with up-to-date data.
--
error compiling committee.c: too many arguments to function
From aliguori at us.ibm.com Mon Apr 4 14:19:36 2011
From: aliguori at us.ibm.com (Anthony Liguori)
Date: Mon, 04 Apr 2011 09:19:36 -0500
Subject: [libvirt] [Qemu-devel] [PATCH v2 3/3] raw-posix: Re-open host
CD-ROM after media change
In-Reply-To: <20110404131639.GB13616@redhat.com>
References: <1301425482-8722-1-git-send-email-stefanha@linux.vnet.ibm.com>
<1301425482-8722-4-git-send-email-stefanha@linux.vnet.ibm.com>
<20110404104753.GX13616@redhat.com> <4D99C162.7060706@us.ibm.com>
<20110404131639.GB13616@redhat.com>
Message-ID: <4D99D378.8030206@us.ibm.com>
On 04/04/2011 08:16 AM, Daniel P. Berrange wrote:
> That doesn't really have any impact. If a desktop user is logged
> in, udev may change the ownership to match that user, but if they
> aren't, then udev may reset it to root:disk. Either way, QEMU
> may loose permissions to the disk.
Then if you create a guest without being in the 'disk' group, it'll
fail. That's pretty expected AFAICT.
But with libvirt today, when you launch a guest, your security context
doesn't matter and there's no way you can control what context the guest
gets. libvirt is essentially creating it's own authorization
mechanism. Supporting ACLs goes much further down that path.
>> How much of a leap would it be to spawn a guest with the credentials
>> of the user that created/defined it? Or better yet, to let the user
>> be specified in the XML.
> That's a completely independent RFE which won't fix this issue in
> the general case.
I think it really does.
Regards,
Anthony Liguori
> Regards,
> Daniel
From berrange at redhat.com Mon Apr 4 14:26:12 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 15:26:12 +0100
Subject: [libvirt] [Qemu-devel] [PATCH v2 3/3] raw-posix: Re-open host
CD-ROM after media change
In-Reply-To: <4D99D378.8030206@us.ibm.com>
References: <1301425482-8722-1-git-send-email-stefanha@linux.vnet.ibm.com>
<1301425482-8722-4-git-send-email-stefanha@linux.vnet.ibm.com>
<20110404104753.GX13616@redhat.com> <4D99C162.7060706@us.ibm.com>
<20110404131639.GB13616@redhat.com> <4D99D378.8030206@us.ibm.com>
Message-ID: <20110404142612.GD13616@redhat.com>
On Mon, Apr 04, 2011 at 09:19:36AM -0500, Anthony Liguori wrote:
> On 04/04/2011 08:16 AM, Daniel P. Berrange wrote:
> >That doesn't really have any impact. If a desktop user is logged
> >in, udev may change the ownership to match that user, but if they
> >aren't, then udev may reset it to root:disk. Either way, QEMU
> >may loose permissions to the disk.
>
> Then if you create a guest without being in the 'disk' group, it'll
> fail. That's pretty expected AFAICT.
We don't *ever* want to put QEMU in the 'disk' group because
that gives it access to any disk on the system in general.
> But with libvirt today, when you launch a guest, your security
> context doesn't matter and there's no way you can control what
> context the guest gets. libvirt is essentially creating it's own
> authorization mechanism. Supporting ACLs goes much further down
> that path.
>
> >>How much of a leap would it be to spawn a guest with the credentials
> >>of the user that created/defined it? Or better yet, to let the user
> >>be specified in the XML.
> >That's a completely independent RFE which won't fix this issue in
> >the general case.
>
> I think it really does.
Nope it doesn't.
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From veillard at redhat.com Mon Apr 4 14:42:21 2011
From: veillard at redhat.com (Daniel Veillard)
Date: Mon, 4 Apr 2011 22:42:21 +0800
Subject: [libvirt] [PATCH 1/2] extend logging to record
configuration-related events on host machine
In-Reply-To: <1301300027-5858-2-git-send-email-n-horiguchi@ah.jp.nec.com>
References: <1301300027-5858-1-git-send-email-n-horiguchi@ah.jp.nec.com>
<1301300027-5858-2-git-send-email-n-horiguchi@ah.jp.nec.com>
Message-ID: <20110404144221.GU24385@redhat.com>
[ OOPs actually I wrote this reply wednesday last week but forgot to
send it, sorry , Daniel ]
On Mon, Mar 28, 2011 at 05:13:46PM +0900, Naoya Horiguchi wrote:
> Currently libvirt's logging is so poor that it's difficult to determine
> what was happening when a proglem occurred (especially on someone's
Actually libvirt logging is fairly complete, but the default
logging at the INFO level is not complete, which can be a problem
for a prosteriori analysis.
http://libvirt.org/logging.html
I tried to fix this for serious problems like crashes
https://www.redhat.com/archives/libvir-list/2011-March/msg00072.html
but for continuous default logging, yeah we could be a bit more verbose
> machines you don't know the detail.) This patch helps us to do that
> by making additional logging available for the following events:
>
> creating/defining/undefining domains
> creating/defining/undefining/starting/stopping networks
> creating/defining/undefining/starting/stopping storage pools
> creating/defining/undefining/starting/stopping storage volumes.
Okay, makes sense to me. ACK,
> Signed-off-by: Naoya Horiguchi
> ---
> src/network/bridge_driver.c | 4 ++++
> src/qemu/qemu_driver.c | 5 ++++-
> src/storage/storage_driver.c | 12 ++++++++++++
> 3 files changed, 20 insertions(+), 1 deletions(-)
>
> diff --git v0.8.8/src/network/bridge_driver.c v0.8.8/src/network/bridge_driver.c
Note: your patch didn't applied cleanly because you developped it
against a released versions, it's better to do this against libvirt
git head. I rebased it solving the couple of conflict, it was easy,
thanks !
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel at veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
From anthony at codemonkey.ws Mon Apr 4 14:43:44 2011
From: anthony at codemonkey.ws (Anthony Liguori)
Date: Mon, 04 Apr 2011 09:43:44 -0500
Subject: [libvirt] [Qemu-devel] [PATCH v2 3/3] raw-posix: Re-open host
CD-ROM after media change
In-Reply-To: <20110404142612.GD13616@redhat.com>
References: <1301425482-8722-1-git-send-email-stefanha@linux.vnet.ibm.com> <1301425482-8722-4-git-send-email-stefanha@linux.vnet.ibm.com> <20110404104753.GX13616@redhat.com>
<4D99C162.7060706@us.ibm.com> <20110404131639.GB13616@redhat.com>
<4D99D378.8030206@us.ibm.com> <20110404142612.GD13616@redhat.com>
Message-ID: <4D99D920.1040800@codemonkey.ws>
On 04/04/2011 09:26 AM, Daniel P. Berrange wrote:
> On Mon, Apr 04, 2011 at 09:19:36AM -0500, Anthony Liguori wrote:
>> On 04/04/2011 08:16 AM, Daniel P. Berrange wrote:
>>> That doesn't really have any impact. If a desktop user is logged
>>> in, udev may change the ownership to match that user, but if they
>>> aren't, then udev may reset it to root:disk. Either way, QEMU
>>> may loose permissions to the disk.
>> Then if you create a guest without being in the 'disk' group, it'll
>> fail. That's pretty expected AFAICT.
> We don't *ever* want to put QEMU in the 'disk' group because
> that gives it access to any disk on the system in general.
If that's what the user wants to do, what's the problem with doing it?
Setting the global user/group is not enough because just because you
have one VM that you want in disk doesn't mean you want all of them in disk.
And to be clear, if you could do this today, there wouldn't be a problem
here in terms of QEMU just reopening the file.
Regards,
Anthony Liguori
Regards,
Anthony Liguori
From berrange at redhat.com Mon Apr 4 14:55:26 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 15:55:26 +0100
Subject: [libvirt] [PATCH 2/2] qemu: extend logging to record guest
configuration events
In-Reply-To: <1301300027-5858-3-git-send-email-n-horiguchi@ah.jp.nec.com>
References: <1301300027-5858-1-git-send-email-n-horiguchi@ah.jp.nec.com>
<1301300027-5858-3-git-send-email-n-horiguchi@ah.jp.nec.com>
Message-ID: <20110404145526.GE13616@redhat.com>
On Mon, Mar 28, 2011 at 05:13:47PM +0900, Naoya Horiguchi wrote:
> The following events can be logged onto /var/log/libvirt/qemu/.log:
>
> starting/shutting down/suspending/resuming/migrating domains
> changing the amount of memory
> changing the number of VCPUs
> inserting/ejecting a media into/from CDROM/Floppy devices
> attaching/detaching PCI/SCSI/USB devices (including NICs and disks.)
>
> This patch generalizes qemudLog*() introduced in commit 93bc093ac
> to handle the whole range of qemu driver's events.
>
> This is useful for the same reason as explainged in the previous patch.
I think we need to think about the question of logging
in a more thorough way.
- libvirt.c: Logs invocation of every API call
- qemu/driver.c/qemu_audit.c: Logs major lifecycle changes &
any config change that is related host resources
- virterror.c: Logs any API call that results in an error
- qemu_driver.c: Logs a set of lifecycle/config changes
(your previous patch 1/2) at VIR_INFO
- qemu_driver.c: Logs a different set of lifecycle/config
changes in /var/log/libvirt/qemu/.loog
I don't think the latter two are particularly great because
they are only cover a fraction of the API calls in the QEMU
driver. libvirt.c has full logging cover, but it only covers
API calls, it doesn't indicate whether it was successful or
failed.
For SystemTAP, we likely want to add probes to libvirt.c
which will log initial parameters, and the return values.
Our SystemTAP probe macros also generate log statements.
A further complication is that /var/log/libvirt/qemu/$NAME.log
is intended for QEMU's stderr output. The only time that
libvirtd currently writes to it, is before QEMU starts and after
it has shutdown.
This new patch means that libvirtd writes to it while QEMU is
running, which is not really safe because you can now end up
with 2 proceses writing to the same file at once. The log
messages may well get interleaved/corrupted by each other.
I don't think that is good for something that wants to be
used as a formal record of operations on a VM.
I think that in each driver we only really want to have to
insert one set of formal "operation logging" calls. Since
we already have the audit APIs present, I think we could try
to make use of that to generate a record of operations against
a VM in some way.
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From stefanha at gmail.com Mon Apr 4 15:09:05 2011
From: stefanha at gmail.com (Stefan Hajnoczi)
Date: Mon, 4 Apr 2011 16:09:05 +0100
Subject: [libvirt] [Qemu-devel] [PATCH v2 3/3] raw-posix: Re-open host
CD-ROM after media change
In-Reply-To: <4D99CC74.9070703@redhat.com>
References: <1301425482-8722-1-git-send-email-stefanha@linux.vnet.ibm.com>
<1301425482-8722-4-git-send-email-stefanha@linux.vnet.ibm.com>
<4D99C61E.3080600@redhat.com> <4D99C9ED.3020602@codemonkey.ws>
<4D99CC74.9070703@redhat.com>
Message-ID:
On Mon, Apr 4, 2011 at 2:49 PM, Avi Kivity wrote:
> On 04/04/2011 04:38 PM, Anthony Liguori wrote:
>>
>> On 04/04/2011 08:22 AM, Avi Kivity wrote:
>>>
>>> On 04/03/2011 02:57 PM, Stefan Hajnoczi wrote:
>>>>
>>>> In order for media change to work with Linux host CD-ROM it is
>>>> necessary to reopen the file (otherwise the inode size will not
>>>> refresh, this is an issue with existing kernels).
>>>>
>>>
>>> Maybe we should fix the bug in Linux (and backport as necessary)?
>>>
>>> I think cd-rom assignment is sufficiently obscure that we can require a
>>> fixed kernel instead of providing a workaround.
>>
>> Do reads fail after CD change? ?Or do they succeed and the size is just
>> reported incorrectly?
>>
>> If it's the later, I'd agree that it needs fixing in the kernel. ?If it's
>> the former, I'd say it's clearly a feature.
>>
>
> Even if it's a documented or intentional feature, we can add an ioctl to
> "refresh" the device with up-to-date data.
It's possible to fix this in the kernel. I just haven't written the
patch yet. The inode size needs to be updated when the new medium is
detected.
I haven't tested but I suspect reads within the size of the previous
medium will succeed. But if the new medium is larger then reads
beyond the old medium size will fail.
The size reported by lseek(fd, 0, SEEK_END) is outdated.
Stefan
From avi at redhat.com Mon Apr 4 15:11:20 2011
From: avi at redhat.com (Avi Kivity)
Date: Mon, 04 Apr 2011 18:11:20 +0300
Subject: [libvirt] [Qemu-devel] [PATCH v2 3/3] raw-posix: Re-open host
CD-ROM after media change
In-Reply-To:
References: <1301425482-8722-1-git-send-email-stefanha@linux.vnet.ibm.com> <1301425482-8722-4-git-send-email-stefanha@linux.vnet.ibm.com> <4D99C61E.3080600@redhat.com> <4D99C9ED.3020602@codemonkey.ws> <4D99CC74.9070703@redhat.com>
Message-ID: <4D99DF98.2030708@redhat.com>
On 04/04/2011 06:09 PM, Stefan Hajnoczi wrote:
> On Mon, Apr 4, 2011 at 2:49 PM, Avi Kivity wrote:
> > On 04/04/2011 04:38 PM, Anthony Liguori wrote:
> >>
> >> On 04/04/2011 08:22 AM, Avi Kivity wrote:
> >>>
> >>> On 04/03/2011 02:57 PM, Stefan Hajnoczi wrote:
> >>>>
> >>>> In order for media change to work with Linux host CD-ROM it is
> >>>> necessary to reopen the file (otherwise the inode size will not
> >>>> refresh, this is an issue with existing kernels).
> >>>>
> >>>
> >>> Maybe we should fix the bug in Linux (and backport as necessary)?
> >>>
> >>> I think cd-rom assignment is sufficiently obscure that we can require a
> >>> fixed kernel instead of providing a workaround.
> >>
> >> Do reads fail after CD change? Or do they succeed and the size is just
> >> reported incorrectly?
> >>
> >> If it's the later, I'd agree that it needs fixing in the kernel. If it's
> >> the former, I'd say it's clearly a feature.
> >>
> >
> > Even if it's a documented or intentional feature, we can add an ioctl to
> > "refresh" the device with up-to-date data.
>
> It's possible to fix this in the kernel. I just haven't written the
> patch yet. The inode size needs to be updated when the new medium is
> detected.
>
> I haven't tested but I suspect reads within the size of the previous
> medium will succeed. But if the new medium is larger then reads
> beyond the old medium size will fail.
>
> The size reported by lseek(fd, 0, SEEK_END) is outdated.
I believe a kernel fix is best in that case, leaving qemu alone.
--
error compiling committee.c: too many arguments to function
From berrange at redhat.com Mon Apr 4 16:19:58 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 17:19:58 +0100
Subject: [libvirt] [PATCH 0/6] Switch to use gnulib's manywarnings
Message-ID: <1301934004-6204-1-git-send-email-berrange@redhat.com>
A second version of
http://www.redhat.com/archives/libvir-list/2011-April/msg00060.html
In this version:
- Move acinclude.m4 into m4/
- Don't blacklist -W, only use -Wno-sign-compare
- Fix some issues allowing further warnings to be turned on
- Increase max stack size to 65700 bytes to make test suite
compile. Test suite to be fixed later :-)
From berrange at redhat.com Mon Apr 4 16:19:59 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 17:19:59 +0100
Subject: [libvirt] [PATCH 1/6] Use gnulib's manywarnings & warnings modules
In-Reply-To: <1301934004-6204-1-git-send-email-berrange@redhat.com>
References: <1301934004-6204-1-git-send-email-berrange@redhat.com>
Message-ID: <1301934004-6204-2-git-send-email-berrange@redhat.com>
Remove custom code for checking compiler warnings, using
gl_WARN_ADD instead. Don't list all flags ourselves, use
gnulib's gl_MANYWARN_ALL_GCC to get all possible GCC flags,
then turn off the ones we don't want yet.
* acinclude.m4: Rewrite to use gl_WARN_ADD and gl_MANYWARN_ALL_GCC
* bootstrap.conf: Add warnings & manywarnings
* configure.ac: Switch to gl_WARN_ADD
* m4/compiler-flags.m4: Obsoleted by gl_WARN_ADD
---
acinclude.m4 | 158 +++++++++++++++++++++++++++-----------------------
bootstrap.conf | 2 +
configure.ac | 15 +++--
m4/compiler-flags.m4 | 48 ---------------
4 files changed, 96 insertions(+), 127 deletions(-)
delete mode 100644 m4/compiler-flags.m4
diff --git a/acinclude.m4 b/acinclude.m4
index 838ec46..8eb0ec5 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -1,11 +1,6 @@
dnl
-dnl Taken from gnome-common/macros2/gnome-compiler-flags.m4
-dnl
-dnl We've added:
-dnl -Wextra -Wshadow -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Winline -Wredundant-decls
-dnl We've removed
-dnl CFLAGS="$realsave_CFLAGS"
-dnl to avoid clobbering user-specified CFLAGS
+dnl Enable all known GCC compiler warnings, except for those
+dnl we can't yet cope with
dnl
AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
dnl ******************************
@@ -13,90 +8,107 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
dnl ******************************
AC_ARG_ENABLE(compile-warnings,
- [AC_HELP_STRING([--enable-compile-warnings=@<:@no/minimum/yes/maximum/error@:>@],
+ [AC_HELP_STRING([--enable-compile-warnings=@<:@no/yes/error@:>@],
[Turn on compiler warnings])],,
- [enable_compile_warnings="m4_default([$1],[maximum])"])
-
- warnCFLAGS=
-
- common_flags=
- common_flags="$common_flags -Wp,-D_FORTIFY_SOURCE=2"
- common_flags="$common_flags -fexceptions"
- common_flags="$common_flags -fasynchronous-unwind-tables"
- common_flags="$common_flags -fdiagnostics-show-option"
+ [enable_compile_warnings="m4_default([$1],[yes])"])
case "$enable_compile_warnings" in
no)
try_compiler_flags=""
;;
- minimum)
- try_compiler_flags="-Wall -Wformat -Wformat-security $common_flags"
- ;;
- yes)
- try_compiler_flags="-Wall -Wformat -Wformat-security -Wmissing-prototypes $common_flags"
- ;;
- maximum|error)
- try_compiler_flags="-Wall -Wformat -Wformat-security"
- try_compiler_flags="$try_compiler_flags -Wmissing-prototypes"
- try_compiler_flags="$try_compiler_flags -Wnested-externs "
- try_compiler_flags="$try_compiler_flags -Wpointer-arith"
- try_compiler_flags="$try_compiler_flags -Wextra -Wshadow"
- try_compiler_flags="$try_compiler_flags -Wcast-align"
- try_compiler_flags="$try_compiler_flags -Wwrite-strings"
- try_compiler_flags="$try_compiler_flags -Waggregate-return"
- try_compiler_flags="$try_compiler_flags -Wstrict-prototypes"
- try_compiler_flags="$try_compiler_flags -Winline"
- try_compiler_flags="$try_compiler_flags -Wredundant-decls"
- try_compiler_flags="$try_compiler_flags -Wno-sign-compare"
- try_compiler_flags="$try_compiler_flags -Wlogical-op"
- try_compiler_flags="$try_compiler_flags $common_flags"
- if test "$enable_compile_warnings" = "error" ; then
- try_compiler_flags="$try_compiler_flags -Werror"
- fi
+ yes|minimum|maximum|error)
+
+ # List of warnings that are not relevant / wanted
+ dontwarn="$dontwarn -Wc++-compat" # Don't care about C++ compiler compat
+ dontwarn="$dontwarn -Wtraditional" # Don't care about ancient C standard compat
+ dontwarn="$dontwarn -Wtraditional-conversion" # Don't care about ancient C standard compat
+ dontwarn="$dontwarn -Wsystem-headers" # Ignore warnings in /usr/include
+ dontwarn="$dontwarn -Wpadded" # Happy for compiler to add struct padding
+ dontwarn="$dontwarn -Wunreachable-code" # GCC very confused with -O2
+ dontwarn="$dontwarn -Wconversion" # Too many to deal with
+ dontwarn="$dontwarn -Wsign-conversion" # Too many to deal with
+ dontwarn="$dontwarn -Wvla" # GNULIB gettext.h violates
+ dontwarn="$dontwarn -Wundef" # Many GNULIB violations
+ dontwarn="$dontwarn -Wcast-qual" # Need to allow bad cast for execve()
+ dontwarn="$dontwarn -Wlong-long" # We need to use long long in many places
+ dontwarn="$dontwarn -Wswitch-default" # We allow manual list of all enum cases without default:
+ dontwarn="$dontwarn -Wswitch-enum" # We allow optional default: instead of listing all enum values
+ dontwarn="$dontwarn -Wstrict-overflow" # Not a problem since we don't use -fstrict-overflow
+ dontwarn="$dontwarn -Wunsafe-loop-optimizations" # Not a problem since we don't use -funsafe-loop-optimizations
+
+ # We might fundamentally need some of these disabled forever, but ideally
+ # we'd turn many of them on
+ dontwarn="$dontwarn -Wformat-nonliteral"
+ dontwarn="$dontwarn -Wfloat-equal"
+ dontwarn="$dontwarn -Wdeclaration-after-statement"
+ dontwarn="$dontwarn -Wcast-qual"
+ dontwarn="$dontwarn -Wconversion"
+ dontwarn="$dontwarn -Wsign-conversion"
+ dontwarn="$dontwarn -Wold-style-definition"
+ dontwarn="$dontwarn -Wmissing-noreturn"
+ dontwarn="$dontwarn -Wpacked"
+ dontwarn="$dontwarn -Wunused-macros"
+ dontwarn="$dontwarn -Woverlength-strings"
+ dontwarn="$dontwarn -Wmissing-format-attribute"
+ dontwarn="$dontwarn -Wstack-protector"
+
+ # Get all possible GCC warnings
+ gl_MANYWARN_ALL_GCC([maybewarn])
+
+ # Remove the ones we don't want, blacklisted earlier
+ gl_MANYWARN_COMPLEMENT([wantwarn], [$maybewarn], [$dontwarn])
+
+ # Check for $CC support of each warning
+ for w in $wantwarn; do
+ gl_WARN_ADD([$w])
+ done
+
+ # GNULIB uses '-W' which includes a bunch of stuff,
+ # kinda like -Wextra. Unfortunately, it means you
+ # can't simply use '-Wsign-compare' with gl_MANYWARN_COMPLEMENT
+ # So we have -W enabled, and then have to explicitly turn off
+ gl_WARN_ADD(-Wno-sign-compare)
+
+ # This should be < 256 really, but with PATH_MAX everywhere
+ # we have doom, even with 4096. In fact we have some functions
+ # with several PATH_MAX sized variables :-( We should kill off
+ # all PATH_MAX usage and then lower this limit
+ gl_WARN_ADD([-Wframe-larger-than=65700])
+ dnl gl_WARN_ADD([-Wframe-larger-than=4096])
+ dnl gl_WARN_ADD([-Wframe-larger-than=256])
+
+ # Extra special flags
+ gl_WARN_ADD([-Wp,-D_FORTIFY_SOURCE=2])
+ dnl Fedora only uses -fstack-protector, but doesn't seem to
+ dnl be great overhead in adding -fstack-protector-all instead
+ dnl gl_WARN_ADD([-fstack-protector])
+ gl_WARN_ADD([-fstack-protector-all])
+ gl_WARN_ADD([--param=ssp-buffer-size=4])
+ gl_WARN_ADD([-fexceptions])
+ gl_WARN_ADD([-fasynchronous-unwind-tables])
+ gl_WARN_ADD([-fdiagnostics-show-option])
+
+ if test "$enable_compile_warnings" = "error"
+ then
+ gl_WARN_ADD([-Werror])
+ fi
;;
*)
AC_MSG_ERROR(Unknown argument '$enable_compile_warnings' to --enable-compile-warnings)
;;
esac
- COMPILER_FLAGS=
- for option in $try_compiler_flags; do
- gl_COMPILER_FLAGS($option)
- done
- unset option
- unset try_compiler_flags
-
- AC_ARG_ENABLE(iso-c,
- AC_HELP_STRING([--enable-iso-c],
- [Try to warn if code is not ISO C ]),,
- [enable_iso_c=no])
-
- AC_MSG_CHECKING(what language compliance flags to pass to the C compiler)
- complCFLAGS=
- if test "x$enable_iso_c" != "xno"; then
- if test "x$GCC" = "xyes"; then
- case " $CFLAGS " in
- *[\ \ ]-ansi[\ \ ]*) ;;
- *) complCFLAGS="$complCFLAGS -ansi" ;;
- esac
- case " $CFLAGS " in
- *[\ \ ]-pedantic[\ \ ]*) ;;
- *) complCFLAGS="$complCFLAGS -pedantic" ;;
- esac
- fi
- fi
- AC_MSG_RESULT($complCFLAGS)
-
- WARN_CFLAGS="$COMPILER_FLAGS $complCFLAGS"
WARN_LDFLAGS=$WARN_CFLAGS
AC_SUBST([WARN_CFLAGS])
AC_SUBST([WARN_LDFLAGS])
dnl Needed to keep compile quiet on python 2.4
- COMPILER_FLAGS=
- gl_COMPILER_FLAGS(-Wno-redundant-decls)
- WARN_PYTHON_CFLAGS=$COMPILER_FLAGS
+ save_WARN_CFLAGS=$WARN_CFLAGS
+ WARN_CFLAGS=
+ gl_WARN_ADD(-Wno-redundant-decls)
+ WARN_PYTHON_CFLAGS=$WARN_CFLAGS
AC_SUBST(WARN_PYTHON_CFLAGS)
+ WARN_CFLAGS=$save_WARN_CFLAGS
])
diff --git a/bootstrap.conf b/bootstrap.conf
index ca0c3de..86aad14 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -45,6 +45,7 @@ ignore-value
inet_pton
ioctl
maintainer-makefile
+manywarnings
mkstemp
mkstemps
mktempd
@@ -81,6 +82,7 @@ timegm
uname
useless-if-before-free
usleep
+warnings
vasprintf
verify
vc-list-files
diff --git a/configure.ac b/configure.ac
index a8d223a..7874c30 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1970,12 +1970,14 @@ AC_ARG_ENABLE([test-coverage],
enable_coverage=$enableval
if test "${enable_coverage}" = yes; then
- COMPILER_FLAGS=
- gl_COMPILER_FLAGS(-fprofile-arcs)
- gl_COMPILER_FLAGS(-ftest-coverage)
- AC_SUBST([COVERAGE_CFLAGS], [$COMPILER_FLAGS])
- AC_SUBST([COVERAGE_LDFLAGS], [$COMPILER_FLAGS])
- COMPILER_FLAGS=
+ save_WARN_CFLAGS=$WARN_CFLAGS
+ WARN_CFLAGS=
+ gl_WARN_ADD(-fprofile-arcs)
+ gl_WARN_ADD(-ftest-coverage)
+ COVERAGE_FLAGS=$WARN_CFLAGS
+ AC_SUBST([COVERAGE_CFLAGS], [$COVERAGE_FLAGS])
+ AC_SUBST([COVERAGE_LDFLAGS], [$COVERAGE_FLAGS])
+ WARN_CFLAGS=$save_WARN_CFLAGS
fi
AC_ARG_ENABLE([test-oom],
@@ -2538,6 +2540,7 @@ AC_MSG_NOTICE([Miscellaneous])
AC_MSG_NOTICE([])
AC_MSG_NOTICE([ Debug: $enable_debug])
AC_MSG_NOTICE([ Warnings: $enable_compile_warnings])
+AC_MSG_NOTICE([Warning Flags: $WARN_CFLAGS])
AC_MSG_NOTICE([ Readline: $lv_use_readline])
AC_MSG_NOTICE([ Python: $with_python])
AC_MSG_NOTICE([ DTrace: $with_dtrace])
diff --git a/m4/compiler-flags.m4 b/m4/compiler-flags.m4
deleted file mode 100644
index 6db4816..0000000
--- a/m4/compiler-flags.m4
+++ /dev/null
@@ -1,48 +0,0 @@
-# serial 4
-# Find valid warning flags for the C Compiler. -*-Autoconf-*-
-#
-# Copyright (C) 2010 Red Hat, Inc.
-# Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301 USA
-
-# Written by Jesse Thilo.
-
-AC_DEFUN([gl_COMPILER_FLAGS],
- [AC_MSG_CHECKING(whether compiler accepts $1)
- ac_save_CFLAGS="$CFLAGS"
- dnl Some flags are dependant, so we set all previously checked
- dnl flags when testing. Except for -Werror which we have to
- dnl check on its own, because some of our compiler flags cause
- dnl warnings from the autoconf test program!
- if test "$1" = "-Werror" ; then
- CFLAGS="$CFLAGS $1"
- else
- CFLAGS="$CFLAGS $COMPILER_FLAGS $1"
- fi
- AC_TRY_LINK([], [], has_option=yes, has_option=no,)
- echo 'int x;' >conftest.c
- $CC $CFLAGS -c conftest.c 2>conftest.err
- ret=$?
- if test $ret != 0 || test -s conftest.err || test $has_option = "no"; then
- AC_MSG_RESULT(no)
- else
- AC_MSG_RESULT(yes)
- COMPILER_FLAGS="$COMPILER_FLAGS $1"
- fi
- CFLAGS="$ac_save_CFLAGS"
- rm -f conftest*
- ])
--
1.7.4
From berrange at redhat.com Mon Apr 4 16:20:00 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 17:20:00 +0100
Subject: [libvirt] [PATCH 2/6] Remove acinclude.m4 file
In-Reply-To: <1301934004-6204-1-git-send-email-berrange@redhat.com>
References: <1301934004-6204-1-git-send-email-berrange@redhat.com>
Message-ID: <1301934004-6204-3-git-send-email-berrange@redhat.com>
Split the bit acinclude.m4 file into smaller pieces named
as m4/virt-XXXXX.m4
* .gitignore: Ignore gettext related files
* acinclude.m4: Delete
* m4/virt-compile-warnings.m4: Checks for GCC compiler flags
* m4/virt-pkgconfig-back-compat.m4: Backcompat check for
pkgconfig program
---
.gitignore | 36 +++++++++-
acinclude.m4 | 137 --------------------------------------
m4/virt-compile-warnings.m4 | 112 +++++++++++++++++++++++++++++++
m4/virt-pkgconfig-back-compat.m4 | 23 ++++++
4 files changed, 169 insertions(+), 139 deletions(-)
delete mode 100644 acinclude.m4
create mode 100644 m4/virt-compile-warnings.m4
create mode 100644 m4/virt-pkgconfig-back-compat.m4
diff --git a/.gitignore b/.gitignore
index ba4d351..278bc4f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,3 @@
-!/m4/compiler-flags.m4
!/po/*.po
!/po/POTFILES.in
!/po/libvirt.pot
@@ -46,7 +45,6 @@
/libvirt.spec
/ltconfig
/ltmain.sh
-/m4/
/maint.mk
/mingw32-libvirt.spec
/mkinstalldirs
@@ -67,3 +65,37 @@ results.log
stamp-h
stamp-h.in
stamp-h1
+m4/codeset.m4
+m4/gettext.m4
+m4/glibc21.m4
+m4/iconv.m4
+m4/intdiv0.m4
+m4/intmax.m4
+m4/inttypes_h.m4
+m4/inttypes.m4
+m4/inttypes-pri.m4
+m4/isc-posix.m4
+m4/lcmessage.m4
+m4/lib-ld.m4
+m4/lib-link.m4
+m4/lib-prefix.m4
+m4/libtool.m4
+m4/longdouble.m4
+m4/longlong.m4
+m4/lt~obsolete.m4
+m4/ltoptions.m4
+m4/ltsugar.m4
+m4/ltversion.m4
+m4/nls.m4
+m4/po.m4
+m4/printf-posix.m4
+m4/progtest.m4
+m4/signed.m4
+m4/size_max.m4
+m4/stdint_h.m4
+m4/uintmax_t.m4
+m4/ulonglong.m4
+m4/wchar_t.m4
+m4/wint_t.m4
+m4/xsize.m4
+m4/.gitignore
diff --git a/acinclude.m4 b/acinclude.m4
deleted file mode 100644
index 8eb0ec5..0000000
--- a/acinclude.m4
+++ /dev/null
@@ -1,137 +0,0 @@
-dnl
-dnl Enable all known GCC compiler warnings, except for those
-dnl we can't yet cope with
-dnl
-AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
- dnl ******************************
- dnl More compiler warnings
- dnl ******************************
-
- AC_ARG_ENABLE(compile-warnings,
- [AC_HELP_STRING([--enable-compile-warnings=@<:@no/yes/error@:>@],
- [Turn on compiler warnings])],,
- [enable_compile_warnings="m4_default([$1],[yes])"])
-
- case "$enable_compile_warnings" in
- no)
- try_compiler_flags=""
- ;;
- yes|minimum|maximum|error)
-
- # List of warnings that are not relevant / wanted
- dontwarn="$dontwarn -Wc++-compat" # Don't care about C++ compiler compat
- dontwarn="$dontwarn -Wtraditional" # Don't care about ancient C standard compat
- dontwarn="$dontwarn -Wtraditional-conversion" # Don't care about ancient C standard compat
- dontwarn="$dontwarn -Wsystem-headers" # Ignore warnings in /usr/include
- dontwarn="$dontwarn -Wpadded" # Happy for compiler to add struct padding
- dontwarn="$dontwarn -Wunreachable-code" # GCC very confused with -O2
- dontwarn="$dontwarn -Wconversion" # Too many to deal with
- dontwarn="$dontwarn -Wsign-conversion" # Too many to deal with
- dontwarn="$dontwarn -Wvla" # GNULIB gettext.h violates
- dontwarn="$dontwarn -Wundef" # Many GNULIB violations
- dontwarn="$dontwarn -Wcast-qual" # Need to allow bad cast for execve()
- dontwarn="$dontwarn -Wlong-long" # We need to use long long in many places
- dontwarn="$dontwarn -Wswitch-default" # We allow manual list of all enum cases without default:
- dontwarn="$dontwarn -Wswitch-enum" # We allow optional default: instead of listing all enum values
- dontwarn="$dontwarn -Wstrict-overflow" # Not a problem since we don't use -fstrict-overflow
- dontwarn="$dontwarn -Wunsafe-loop-optimizations" # Not a problem since we don't use -funsafe-loop-optimizations
-
- # We might fundamentally need some of these disabled forever, but ideally
- # we'd turn many of them on
- dontwarn="$dontwarn -Wformat-nonliteral"
- dontwarn="$dontwarn -Wfloat-equal"
- dontwarn="$dontwarn -Wdeclaration-after-statement"
- dontwarn="$dontwarn -Wcast-qual"
- dontwarn="$dontwarn -Wconversion"
- dontwarn="$dontwarn -Wsign-conversion"
- dontwarn="$dontwarn -Wold-style-definition"
- dontwarn="$dontwarn -Wmissing-noreturn"
- dontwarn="$dontwarn -Wpacked"
- dontwarn="$dontwarn -Wunused-macros"
- dontwarn="$dontwarn -Woverlength-strings"
- dontwarn="$dontwarn -Wmissing-format-attribute"
- dontwarn="$dontwarn -Wstack-protector"
-
- # Get all possible GCC warnings
- gl_MANYWARN_ALL_GCC([maybewarn])
-
- # Remove the ones we don't want, blacklisted earlier
- gl_MANYWARN_COMPLEMENT([wantwarn], [$maybewarn], [$dontwarn])
-
- # Check for $CC support of each warning
- for w in $wantwarn; do
- gl_WARN_ADD([$w])
- done
-
- # GNULIB uses '-W' which includes a bunch of stuff,
- # kinda like -Wextra. Unfortunately, it means you
- # can't simply use '-Wsign-compare' with gl_MANYWARN_COMPLEMENT
- # So we have -W enabled, and then have to explicitly turn off
- gl_WARN_ADD(-Wno-sign-compare)
-
- # This should be < 256 really, but with PATH_MAX everywhere
- # we have doom, even with 4096. In fact we have some functions
- # with several PATH_MAX sized variables :-( We should kill off
- # all PATH_MAX usage and then lower this limit
- gl_WARN_ADD([-Wframe-larger-than=65700])
- dnl gl_WARN_ADD([-Wframe-larger-than=4096])
- dnl gl_WARN_ADD([-Wframe-larger-than=256])
-
- # Extra special flags
- gl_WARN_ADD([-Wp,-D_FORTIFY_SOURCE=2])
- dnl Fedora only uses -fstack-protector, but doesn't seem to
- dnl be great overhead in adding -fstack-protector-all instead
- dnl gl_WARN_ADD([-fstack-protector])
- gl_WARN_ADD([-fstack-protector-all])
- gl_WARN_ADD([--param=ssp-buffer-size=4])
- gl_WARN_ADD([-fexceptions])
- gl_WARN_ADD([-fasynchronous-unwind-tables])
- gl_WARN_ADD([-fdiagnostics-show-option])
-
- if test "$enable_compile_warnings" = "error"
- then
- gl_WARN_ADD([-Werror])
- fi
- ;;
- *)
- AC_MSG_ERROR(Unknown argument '$enable_compile_warnings' to --enable-compile-warnings)
- ;;
- esac
-
- WARN_LDFLAGS=$WARN_CFLAGS
- AC_SUBST([WARN_CFLAGS])
- AC_SUBST([WARN_LDFLAGS])
-
- dnl Needed to keep compile quiet on python 2.4
- save_WARN_CFLAGS=$WARN_CFLAGS
- WARN_CFLAGS=
- gl_WARN_ADD(-Wno-redundant-decls)
- WARN_PYTHON_CFLAGS=$WARN_CFLAGS
- AC_SUBST(WARN_PYTHON_CFLAGS)
- WARN_CFLAGS=$save_WARN_CFLAGS
-])
-
-
-dnl
-dnl To support the old pkg-config from RHEL4 vintage, we need
-dnl to define the PKG_PROG_PKG_CONFIG macro if its not already
-dnl present
-m4_ifndef([PKG_PROG_PKG_CONFIG],
- [AC_DEFUN([PKG_PROG_PKG_CONFIG],
-[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
-m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
-AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl
-if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
- AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
-fi
-if test -n "$PKG_CONFIG"; then
- _pkg_min_version=m4_default([$1], [0.9.0])
- AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
- if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
- AC_MSG_RESULT([yes])
- else
- AC_MSG_RESULT([no])
- PKG_CONFIG=""
- fi
-fi[]dnl
-])])
diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4
new file mode 100644
index 0000000..f8ee474
--- /dev/null
+++ b/m4/virt-compile-warnings.m4
@@ -0,0 +1,112 @@
+dnl
+dnl Enable all known GCC compiler warnings, except for those
+dnl we can't yet cope with
+dnl
+AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
+ dnl ******************************
+ dnl More compiler warnings
+ dnl ******************************
+
+ AC_ARG_ENABLE(compile-warnings,
+ [AC_HELP_STRING([--enable-compile-warnings=@<:@no/yes/error@:>@],
+ [Turn on compiler warnings])],,
+ [enable_compile_warnings="m4_default([$1],[yes])"])
+
+ case "$enable_compile_warnings" in
+ no)
+ try_compiler_flags=""
+ ;;
+ yes|minimum|maximum|error)
+
+ # List of warnings that are not relevant / wanted
+ dontwarn="$dontwarn -Wc++-compat" # Don't care about C++ compiler compat
+ dontwarn="$dontwarn -Wtraditional" # Don't care about ancient C standard compat
+ dontwarn="$dontwarn -Wtraditional-conversion" # Don't care about ancient C standard compat
+ dontwarn="$dontwarn -Wsystem-headers" # Ignore warnings in /usr/include
+ dontwarn="$dontwarn -Wpadded" # Happy for compiler to add struct padding
+ dontwarn="$dontwarn -Wunreachable-code" # GCC very confused with -O2
+ dontwarn="$dontwarn -Wconversion" # Too many to deal with
+ dontwarn="$dontwarn -Wsign-conversion" # Too many to deal with
+ dontwarn="$dontwarn -Wvla" # GNULIB gettext.h violates
+ dontwarn="$dontwarn -Wundef" # Many GNULIB violations
+ dontwarn="$dontwarn -Wcast-qual" # Need to allow bad cast for execve()
+ dontwarn="$dontwarn -Wlong-long" # We need to use long long in many places
+ dontwarn="$dontwarn -Wswitch-default" # We allow manual list of all enum cases without default:
+ dontwarn="$dontwarn -Wswitch-enum" # We allow optional default: instead of listing all enum values
+ dontwarn="$dontwarn -Wstrict-overflow" # Not a problem since we don't use -fstrict-overflow
+ dontwarn="$dontwarn -Wunsafe-loop-optimizations" # Not a problem since we don't use -funsafe-loop-optimizations
+
+ # We might fundamentally need some of these disabled forever, but ideally
+ # we'd turn many of them on
+ dontwarn="$dontwarn -Wformat-nonliteral"
+ dontwarn="$dontwarn -Wfloat-equal"
+ dontwarn="$dontwarn -Wdeclaration-after-statement"
+ dontwarn="$dontwarn -Wcast-qual"
+ dontwarn="$dontwarn -Wconversion"
+ dontwarn="$dontwarn -Wsign-conversion"
+ dontwarn="$dontwarn -Wold-style-definition"
+ dontwarn="$dontwarn -Wmissing-noreturn"
+ dontwarn="$dontwarn -Wpacked"
+ dontwarn="$dontwarn -Wunused-macros"
+ dontwarn="$dontwarn -Woverlength-strings"
+ dontwarn="$dontwarn -Wmissing-format-attribute"
+ dontwarn="$dontwarn -Wstack-protector"
+
+ # Get all possible GCC warnings
+ gl_MANYWARN_ALL_GCC([maybewarn])
+
+ # Remove the ones we don't want, blacklisted earlier
+ gl_MANYWARN_COMPLEMENT([wantwarn], [$maybewarn], [$dontwarn])
+
+ # Check for $CC support of each warning
+ for w in $wantwarn; do
+ gl_WARN_ADD([$w])
+ done
+
+ # GNULIB uses '-W' which includes a bunch of stuff,
+ # kinda like -Wextra. Unfortunately, it means you
+ # can't simply use '-Wsign-compare' with gl_MANYWARN_COMPLEMENT
+ # So we have -W enabled, and then have to explicitly turn off
+ gl_WARN_ADD(-Wno-sign-compare)
+
+ # This should be < 256 really, but with PATH_MAX everywhere
+ # we have doom, even with 4096. In fact we have some functions
+ # with several PATH_MAX sized variables :-( We should kill off
+ # all PATH_MAX usage and then lower this limit
+ gl_WARN_ADD([-Wframe-larger-than=65700])
+ dnl gl_WARN_ADD([-Wframe-larger-than=4096])
+ dnl gl_WARN_ADD([-Wframe-larger-than=256])
+
+ # Extra special flags
+ gl_WARN_ADD([-Wp,-D_FORTIFY_SOURCE=2])
+ dnl Fedora only uses -fstack-protector, but doesn't seem to
+ dnl be great overhead in adding -fstack-protector-all instead
+ dnl gl_WARN_ADD([-fstack-protector])
+ gl_WARN_ADD([-fstack-protector-all])
+ gl_WARN_ADD([--param=ssp-buffer-size=4])
+ gl_WARN_ADD([-fexceptions])
+ gl_WARN_ADD([-fasynchronous-unwind-tables])
+ gl_WARN_ADD([-fdiagnostics-show-option])
+
+ if test "$enable_compile_warnings" = "error"
+ then
+ gl_WARN_ADD([-Werror])
+ fi
+ ;;
+ *)
+ AC_MSG_ERROR(Unknown argument '$enable_compile_warnings' to --enable-compile-warnings)
+ ;;
+ esac
+
+ WARN_LDFLAGS=$WARN_CFLAGS
+ AC_SUBST([WARN_CFLAGS])
+ AC_SUBST([WARN_LDFLAGS])
+
+ dnl Needed to keep compile quiet on python 2.4
+ save_WARN_CFLAGS=$WARN_CFLAGS
+ WARN_CFLAGS=
+ gl_WARN_ADD(-Wno-redundant-decls)
+ WARN_PYTHON_CFLAGS=$WARN_CFLAGS
+ AC_SUBST(WARN_PYTHON_CFLAGS)
+ WARN_CFLAGS=$save_WARN_CFLAGS
+])
diff --git a/m4/virt-pkgconfig-back-compat.m4 b/m4/virt-pkgconfig-back-compat.m4
new file mode 100644
index 0000000..7eab84b
--- /dev/null
+++ b/m4/virt-pkgconfig-back-compat.m4
@@ -0,0 +1,23 @@
+dnl
+dnl To support the old pkg-config from RHEL4 vintage, we need
+dnl to define the PKG_PROG_PKG_CONFIG macro if its not already
+dnl present
+m4_ifndef([PKG_PROG_PKG_CONFIG],
+ [AC_DEFUN([PKG_PROG_PKG_CONFIG],
+[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
+m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
+AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+ AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
+fi
+if test -n "$PKG_CONFIG"; then
+ _pkg_min_version=m4_default([$1], [0.9.0])
+ AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
+ if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ PKG_CONFIG=""
+ fi
+fi[]dnl
+])])
--
1.7.4
From berrange at redhat.com Mon Apr 4 16:20:01 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 17:20:01 +0100
Subject: [libvirt] [PATCH 3/6] Enable -Wmissing-format-attribute warning
In-Reply-To: <1301934004-6204-1-git-send-email-berrange@redhat.com>
References: <1301934004-6204-1-git-send-email-berrange@redhat.com>
Message-ID: <1301934004-6204-4-git-send-email-berrange@redhat.com>
Add a couple of missing ATTRIBUTE_FMT_PRINTF annotations
* tools/virsh.c, tests/testutils.c: Add printf format attribute
* m4/virt-compile-warnings.m4: Enable -Wmissing-format-attribute
---
m4/virt-compile-warnings.m4 | 1 -
tests/testutils.c | 2 +-
tools/virsh.c | 3 ++-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4
index f8ee474..51e21a9 100644
--- a/m4/virt-compile-warnings.m4
+++ b/m4/virt-compile-warnings.m4
@@ -49,7 +49,6 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
dontwarn="$dontwarn -Wpacked"
dontwarn="$dontwarn -Wunused-macros"
dontwarn="$dontwarn -Woverlength-strings"
- dontwarn="$dontwarn -Wmissing-format-attribute"
dontwarn="$dontwarn -Wstack-protector"
# Get all possible GCC warnings
diff --git a/tests/testutils.c b/tests/testutils.c
index 3110457..0ce3c7b 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -67,7 +67,7 @@ virtTestCountAverage(double *items, int nitems)
return (double) (sum / nitems);
}
-
+ATTRIBUTE_FMT_PRINTF(3,4)
void virtTestResult(const char *name, int ret, const char *msg, ...)
{
va_list vargs;
diff --git a/tools/virsh.c b/tools/virsh.c
index 19e3449..4765f5c 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -243,7 +243,8 @@ static int vshInit(vshControl *ctl);
static int vshDeinit(vshControl *ctl);
static void vshUsage(void);
static void vshOpenLogFile(vshControl *ctl);
-static void vshOutputLogFile(vshControl *ctl, int log_level, const char *format, va_list ap);
+static void vshOutputLogFile(vshControl *ctl, int log_level, const char *format, va_list ap)
+ ATTRIBUTE_FMT_PRINTF(3, 0);
static void vshCloseLogFile(vshControl *ctl);
static int vshParseArgv(vshControl *ctl, int argc, char **argv);
--
1.7.4
From berrange at redhat.com Mon Apr 4 16:20:02 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 17:20:02 +0100
Subject: [libvirt] [PATCH 4/6] Enable use of -Wmissing-noreturn
In-Reply-To: <1301934004-6204-1-git-send-email-berrange@redhat.com>
References: <1301934004-6204-1-git-send-email-berrange@redhat.com>
Message-ID: <1301934004-6204-5-git-send-email-berrange@redhat.com>
* src/internal.h: Define a ATTRIBUTE_NO_RETURN annotation
* src/lxc/lxc_container.c: Annotate lxcContainerDummyChild
with ATTRIBUTE_NO_RETURN
* tests/eventtest.c: Mark async thread as ATTRIBUTE_NO_RETURN
* m4/virt-compile-warnings.m4: Enable -Wmissing-noreturn
---
m4/virt-compile-warnings.m4 | 1 -
src/internal.h | 9 +++++++++
src/lxc/lxc_container.c | 3 ++-
tests/eventtest.c | 3 +--
4 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4
index 51e21a9..9643419 100644
--- a/m4/virt-compile-warnings.m4
+++ b/m4/virt-compile-warnings.m4
@@ -45,7 +45,6 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
dontwarn="$dontwarn -Wconversion"
dontwarn="$dontwarn -Wsign-conversion"
dontwarn="$dontwarn -Wold-style-definition"
- dontwarn="$dontwarn -Wmissing-noreturn"
dontwarn="$dontwarn -Wpacked"
dontwarn="$dontwarn -Wunused-macros"
dontwarn="$dontwarn -Woverlength-strings"
diff --git a/src/internal.h b/src/internal.h
index 2afbd8d..4641fc1 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -117,6 +117,15 @@
# endif
/**
+ * ATTRIBUTE_NORETURN:
+ *
+ * Macro to indicate that a function won't return to the caller
+ */
+# ifndef ATTRIBUTE_NORETURN
+# define ATTRIBUTE_NORETURN __attribute__((__noreturn__))
+# endif
+
+/**
* ATTRIBUTE_SENTINEL:
*
* Macro to check for NULL-terminated varargs lists
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 9830b71..af453f3 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -914,7 +914,8 @@ int lxcContainerStart(virDomainDefPtr def,
return pid;
}
-static int lxcContainerDummyChild(void *argv ATTRIBUTE_UNUSED)
+ATTRIBUTE_NORETURN static int
+lxcContainerDummyChild(void *argv ATTRIBUTE_UNUSED)
{
_exit(0);
}
diff --git a/tests/eventtest.c b/tests/eventtest.c
index 4d22070..eb4b755 100644
--- a/tests/eventtest.c
+++ b/tests/eventtest.c
@@ -119,7 +119,7 @@ static pthread_cond_t eventThreadJobCond = PTHREAD_COND_INITIALIZER;
static int eventThreadJobDone = 0;
-static void *eventThreadLoop(void *data ATTRIBUTE_UNUSED) {
+ATTRIBUTE_NORETURN static void *eventThreadLoop(void *data ATTRIBUTE_UNUSED) {
while (1) {
pthread_mutex_lock(&eventThreadMutex);
while (!eventThreadRunOnce) {
@@ -135,7 +135,6 @@ static void *eventThreadLoop(void *data ATTRIBUTE_UNUSED) {
pthread_cond_signal(&eventThreadJobCond);
pthread_mutex_unlock(&eventThreadMutex);
}
- return NULL;
}
--
1.7.4
From berrange at redhat.com Mon Apr 4 16:20:03 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 17:20:03 +0100
Subject: [libvirt] [PATCH 5/6] Enable use of -Wold-style-definition compiler
flag
In-Reply-To: <1301934004-6204-1-git-send-email-berrange@redhat.com>
References: <1301934004-6204-1-git-send-email-berrange@redhat.com>
Message-ID: <1301934004-6204-6-git-send-email-berrange@redhat.com>
A couple of functions were declared using the old style foo()
for no-parameters, instead of foo(void)
* src/xen/xen_hypervisor.c, tests/testutils.c: Replace () with (void)
in some function declarations
* m4/virt-compile-warnings.m4: Enable -Wold-style-definition
---
m4/virt-compile-warnings.m4 | 1 -
src/xen/xen_hypervisor.c | 2 +-
tests/testutils.c | 4 ++--
3 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4
index 9643419..24710e6 100644
--- a/m4/virt-compile-warnings.m4
+++ b/m4/virt-compile-warnings.m4
@@ -44,7 +44,6 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
dontwarn="$dontwarn -Wcast-qual"
dontwarn="$dontwarn -Wconversion"
dontwarn="$dontwarn -Wsign-conversion"
- dontwarn="$dontwarn -Wold-style-definition"
dontwarn="$dontwarn -Wpacked"
dontwarn="$dontwarn -Wunused-macros"
dontwarn="$dontwarn -Woverlength-strings"
diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c
index 47355ce..8a9dae5 100644
--- a/src/xen/xen_hypervisor.c
+++ b/src/xen/xen_hypervisor.c
@@ -3621,7 +3621,7 @@ xenHypervisorGetVcpuMax(virDomainPtr domain)
* Return true if the current process should be able to connect to Xen.
*/
int
-xenHavePrivilege()
+xenHavePrivilege(void)
{
#ifdef __sun
return priv_ineffect (PRIV_XVM_CONTROL);
diff --git a/tests/testutils.c b/tests/testutils.c
index 0ce3c7b..1f3b569 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -457,14 +457,14 @@ virTestGetFlag(const char *name) {
}
unsigned int
-virTestGetDebug() {
+virTestGetDebug(void) {
if (testDebug == -1)
testDebug = virTestGetFlag("VIR_TEST_DEBUG");
return testDebug;
}
unsigned int
-virTestGetVerbose() {
+virTestGetVerbose(void) {
if (testVerbose == -1)
testVerbose = virTestGetFlag("VIR_TEST_VERBOSE");
return testVerbose || virTestGetDebug();
--
1.7.4
From berrange at redhat.com Mon Apr 4 16:20:04 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 17:20:04 +0100
Subject: [libvirt] [PATCH 6/6] Remove unused macros and enable
-Wunused-macros
In-Reply-To: <1301934004-6204-1-git-send-email-berrange@redhat.com>
References: <1301934004-6204-1-git-send-email-berrange@redhat.com>
Message-ID: <1301934004-6204-7-git-send-email-berrange@redhat.com>
* m4/virt-compile-warnings.m4: Enable -Wunused-macros
* daemon/libvirtd.c: Remove MAX_LISTEN
* daemon/remote.c: Remote VIR_FROM_THIS
* examples/domain-events/events-c/event-test.c: Remove VIR_DEBUG
* python/libvirt-override.c: Put NAME() inside DEBUG_ERROR
* src/esx/esx*.c: Comment out unused VIR_FROM_THIS
* src/node_device/node_device_hal.c: Remove pointless macros
for accessing privateData
* src/openvz/openvz_driver.c: Remove CMDBUF_LEN/CMDOP_LEN
* src/qemu/qemu_monitor_text.c: Remove QEMU_CMD_PROMPT
and QEMU_PASSWD_PROMPT
* src/remote/remote_driver.c: Remove UNIX_PATH_MAX
* src/security/security_stack.c: Remove VIR_FROM_THIS
* src/uml/uml_conf.c: Remove umlLog()
* src/uml/uml_driver.c: Remove TEMPDIR
* src/util/bridge.c: Remove JIFFIES_TO_MS/MS_TO_JIFFIES
* src/util/hooks.c: Ensure VIR_FROM_THIS is used
* src/util/logging.c: Remove VIR_FROM_THIS
* src/util/macvtap.c: Disable unused constants
* src/util/storage_file.c: Disable QCOW1_HDR_TOTAL_SIZE
* src/vbox/vbox_driver.c: Remove duplicated VIR_FROM_THIS
and make sure it is used
* src/util/pci.c: Disable some unused constants
* src/xen/xen_hypervisor.c: Remove XEN_V0_IOCTL_HYPERCALL_CMD
and unused DOMFLAGS_CPUMASK/DOMFLAGS_CPUSHIFT
* src/xen/xm_internal.c: Remove XM_XML_ERROR,
XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU and
XEND_CONFIG_MIN_VERS_PVFB_NEWCONF
* tools/virsh.c: Remove DIR_MODE/LOCK_MODE, LVL_NOTICE constants
* tests/sockettest.c: Remove DO_TEST_PARSE
---
daemon/libvirtd.c | 2 +-
daemon/remote.c | 1 -
examples/domain-events/events-c/event-test.c | 2 --
m4/virt-compile-warnings.m4 | 1 -
python/libvirt-override.c | 2 ++
src/driver.c | 3 +--
src/esx/esx_device_monitor.c | 2 +-
src/esx/esx_interface_driver.c | 2 +-
src/esx/esx_network_driver.c | 2 +-
src/esx/esx_nwfilter_driver.c | 2 +-
src/esx/esx_secret_driver.c | 2 +-
src/esx/esx_vi.c | 7 -------
src/esx/esx_vi_methods.c | 9 +++++----
src/esx/esx_vi_types.c | 3 ++-
src/libvirt.c | 3 ---
src/node_device/node_device_hal.c | 17 ++++-------------
src/openvz/openvz_driver.c | 2 --
src/qemu/qemu_monitor_text.c | 3 ---
src/remote/remote_driver.c | 3 ---
src/security/security_stack.c | 2 --
src/uml/uml_conf.c | 2 --
src/uml/uml_driver.c | 3 ---
src/util/bridge.c | 3 ---
src/util/hooks.c | 2 +-
src/util/logging.c | 2 --
src/util/macvtap.c | 6 ++++--
src/util/pci.c | 4 ++--
src/util/storage_file.c | 4 +++-
src/vbox/vbox_driver.c | 4 +---
src/xen/xen_hypervisor.c | 14 +++++---------
src/xen/xm_internal.c | 9 ---------
tests/sockettest.c | 10 ----------
tools/virsh.c | 13 ++-----------
33 files changed, 38 insertions(+), 108 deletions(-)
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 024f56f..991aaeb 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -3154,7 +3154,7 @@ enum {
OPT_VERSION = 129
};
-#define MAX_LISTEN 5
+
int main(int argc, char **argv) {
struct qemud_server *server = NULL;
const char *pid_file = NULL;
diff --git a/daemon/remote.c b/daemon/remote.c
index 1700c2d..98279e1 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -62,7 +62,6 @@
#include "libvirt/libvirt-qemu.h"
#include "command.h"
-#define VIR_FROM_THIS VIR_FROM_REMOTE
#define REMOTE_DEBUG(fmt, ...) VIR_DEBUG(fmt, __VA_ARGS__)
static virDomainPtr get_nonnull_domain (virConnectPtr conn, remote_nonnull_domain domain);
diff --git a/examples/domain-events/events-c/event-test.c b/examples/domain-events/events-c/event-test.c
index 1f46d42..3de2aa8 100644
--- a/examples/domain-events/events-c/event-test.c
+++ b/examples/domain-events/events-c/event-test.c
@@ -10,8 +10,6 @@
#define VIR_DEBUG0(fmt) printf("%s:%d :: " fmt "\n", \
__func__, __LINE__)
-#define VIR_DEBUG(fmt, ...) printf("%s:%d: " fmt "\n", \
- __func__, __LINE__, __VA_ARGS__)
#define STREQ(a,b) (strcmp(a,b) == 0)
#ifndef ATTRIBUTE_UNUSED
diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4
index 24710e6..5022676 100644
--- a/m4/virt-compile-warnings.m4
+++ b/m4/virt-compile-warnings.m4
@@ -45,7 +45,6 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
dontwarn="$dontwarn -Wconversion"
dontwarn="$dontwarn -Wsign-conversion"
dontwarn="$dontwarn -Wpacked"
- dontwarn="$dontwarn -Wunused-macros"
dontwarn="$dontwarn -Woverlength-strings"
dontwarn="$dontwarn -Wstack-protector"
diff --git a/python/libvirt-override.c b/python/libvirt-override.c
index 4a9b432..8568ff2 100644
--- a/python/libvirt-override.c
+++ b/python/libvirt-override.c
@@ -2595,7 +2595,9 @@ static char *updateTimeoutName = NULL;
static PyObject *removeTimeoutObj = NULL;
static char *removeTimeoutName = NULL;
+#if DEBUG_ERROR
#define NAME(fn) ( fn ## Name ? fn ## Name : # fn )
+#endif
static int
libvirt_virEventAddHandleFunc (int fd,
diff --git a/src/driver.c b/src/driver.c
index f882ea1..25623cd 100644
--- a/src/driver.c
+++ b/src/driver.c
@@ -30,13 +30,12 @@
#include "util.h"
#include "configmake.h"
-#define DEFAULT_DRIVER_DIR LIBDIR "/libvirt/connection-driver"
-
/* Make sure ... INTERNAL_CALL can not be set by the caller */
verify((VIR_SECRET_GET_VALUE_INTERNAL_CALL &
VIR_SECRET_GET_VALUE_FLAGS_MASK) == 0);
#ifdef WITH_DRIVER_MODULES
+# define DEFAULT_DRIVER_DIR LIBDIR "/libvirt/connection-driver"
/* XXX re-implment this for other OS, or use libtools helper lib ? */
diff --git a/src/esx/esx_device_monitor.c b/src/esx/esx_device_monitor.c
index d559f96..6d765ac 100644
--- a/src/esx/esx_device_monitor.c
+++ b/src/esx/esx_device_monitor.c
@@ -35,7 +35,7 @@
#include "esx_vi_methods.h"
#include "esx_util.h"
-#define VIR_FROM_THIS VIR_FROM_ESX
+/* #define VIR_FROM_THIS VIR_FROM_ESX */
diff --git a/src/esx/esx_interface_driver.c b/src/esx/esx_interface_driver.c
index 4bac3d5..8d0b9a2 100644
--- a/src/esx/esx_interface_driver.c
+++ b/src/esx/esx_interface_driver.c
@@ -35,7 +35,7 @@
#include "esx_vi_methods.h"
#include "esx_util.h"
-#define VIR_FROM_THIS VIR_FROM_ESX
+/* #define VIR_FROM_THIS VIR_FROM_ESX */
diff --git a/src/esx/esx_network_driver.c b/src/esx/esx_network_driver.c
index a64bb8e..7117a60 100644
--- a/src/esx/esx_network_driver.c
+++ b/src/esx/esx_network_driver.c
@@ -35,7 +35,7 @@
#include "esx_vi_methods.h"
#include "esx_util.h"
-#define VIR_FROM_THIS VIR_FROM_ESX
+/* #define VIR_FROM_THIS VIR_FROM_ESX */
diff --git a/src/esx/esx_nwfilter_driver.c b/src/esx/esx_nwfilter_driver.c
index a9d046d..4ba9f46 100644
--- a/src/esx/esx_nwfilter_driver.c
+++ b/src/esx/esx_nwfilter_driver.c
@@ -34,7 +34,7 @@
#include "esx_vi_methods.h"
#include "esx_util.h"
-#define VIR_FROM_THIS VIR_FROM_ESX
+/* #define VIR_FROM_THIS VIR_FROM_ESX */
diff --git a/src/esx/esx_secret_driver.c b/src/esx/esx_secret_driver.c
index 1ae7ddc..350d8e0 100644
--- a/src/esx/esx_secret_driver.c
+++ b/src/esx/esx_secret_driver.c
@@ -34,7 +34,7 @@
#include "esx_vi_methods.h"
#include "esx_util.h"
-#define VIR_FROM_THIS VIR_FROM_ESX
+/* #define VIR_FROM_THIS VIR_FROM_ESX */
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index 7446ec5..3b38937 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -40,13 +40,6 @@
#define VIR_FROM_THIS VIR_FROM_ESX
-
-#define ESX_VI__SOAP__RESPONSE_XPATH(_type) \
- ((char *)"/soapenv:Envelope/soapenv:Body/" \
- "vim:"_type"Response/vim:returnval")
-
-
-
#define ESX_VI__TEMPLATE__ALLOC(_type) \
int \
esxVI_##_type##_Alloc(esxVI_##_type **ptrptr) \
diff --git a/src/esx/esx_vi_methods.c b/src/esx/esx_vi_methods.c
index 5967088..440a62a 100644
--- a/src/esx/esx_vi_methods.c
+++ b/src/esx/esx_vi_methods.c
@@ -1,4 +1,3 @@
-
/*
* esx_vi_methods.c: client for the VMware VI API 2.5 to manage ESX hosts
*
@@ -52,8 +51,10 @@
+#if 0
#define ESX_VI__METHOD__CHECK_OUTPUT__RequiredList \
ESX_VI__METHOD__CHECK_OUTPUT__NotNone
+#endif
@@ -78,12 +79,12 @@
}
-
-#define ESX_VI__METHOD__DESERIALIZE_OUTPUT__RequiredList(_type, _suffix) \
+#if 0
+#define ESX_VI__METHOD__DESERIALIZE_OUTPUT__RequiredList(_type) \
if (esxVI_##_type##_DeserializeList(response->node, output) < 0) { \
goto cleanup; \
}
-
+#endif
#define ESX_VI__METHOD__DESERIALIZE_OUTPUT__OptionalItem(_type, _suffix) \
diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c
index f3df2b5..56121ef 100644
--- a/src/esx/esx_vi_types.c
+++ b/src/esx/esx_vi_types.c
@@ -531,11 +531,12 @@
+#if 0
#define ESX_VI__TEMPLATE__DISPATCH__DEEP_COPY(_type) \
case esxVI_Type_##_type: \
return esxVI_##_type##_DeepCopy((esxVI_##_type **)dst, \
(esxVI_##_type *)src);
-
+#endif
#define ESX_VI__TEMPLATE__DISPATCH__CAST_FROM_ANY_TYPE(_type) \
diff --git a/src/libvirt.c b/src/libvirt.c
index 8be18d4..564988b 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -492,9 +492,6 @@ DllMain (HINSTANCE instance ATTRIBUTE_UNUSED,
#define virLibSecretError(code, ...) \
virReportErrorHelper(NULL, VIR_FROM_SECRET, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
-#define virLibStreamError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_STREAMS, code, __FILE__, \
- __FUNCTION__, __LINE__, __VA_ARGS__)
#define virLibNWFilterError(code, ...) \
virReportErrorHelper(NULL, VIR_FROM_NWFILTER, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_device_hal.c
index 3af2bcf..b4a4c73 100644
--- a/src/node_device/node_device_hal.c
+++ b/src/node_device/node_device_hal.c
@@ -38,21 +38,12 @@
#include "logging.h"
#include "node_device_driver.h"
-#define VIR_FROM_THIS VIR_FROM_NODEDEV
-
/*
* Host device enumeration (HAL implementation)
*/
static virDeviceMonitorStatePtr driverState;
-#define CONN_DRV_STATE(conn) \
- ((virDeviceMonitorStatePtr)((conn)->devMonPrivateData))
-#define DRV_STATE_HAL_CTX(ds) ((LibHalContext *)((ds)->privateData))
-#define CONN_HAL_CTX(conn) DRV_STATE_HAL_CTX(CONN_DRV_STATE(conn))
-
-#define NODE_DEV_UDI(obj) ((const char *)((obj)->privateData)
-
static const char *hal_name(const char *udi)
{
@@ -441,7 +432,7 @@ static void dev_create(const char *udi)
return;
nodeDeviceLock(driverState);
- ctx = DRV_STATE_HAL_CTX(driverState);
+ ctx = driverState->privateData;
if (VIR_ALLOC(def) < 0)
goto failure;
@@ -600,7 +591,7 @@ static void dbus_watch_callback(int fdatch ATTRIBUTE_UNUSED,
(void)dbus_watch_handle(watch, dbus_flags);
nodeDeviceLock(driverState);
- hal_ctx = DRV_STATE_HAL_CTX(driverState);
+ hal_ctx = driverState->privateData;
dbus_conn = libhal_ctx_get_dbus_connection(hal_ctx);
nodeDeviceUnlock(driverState);
while (dbus_connection_dispatch(dbus_conn) == DBUS_DISPATCH_DATA_REMAINS)
@@ -808,7 +799,7 @@ static int halDeviceMonitorShutdown(void)
{
if (driverState) {
nodeDeviceLock(driverState);
- LibHalContext *hal_ctx = DRV_STATE_HAL_CTX(driverState);
+ LibHalContext *hal_ctx = driverState->privateData;
virNodeDeviceObjListFree(&driverState->devs);
(void)libhal_ctx_shutdown(hal_ctx, NULL);
(void)libhal_ctx_free(hal_ctx);
@@ -834,7 +825,7 @@ static int halDeviceMonitorReload(void)
virNodeDeviceObjListFree(&driverState->devs);
nodeDeviceUnlock(driverState);
- hal_ctx = DRV_STATE_HAL_CTX(driverState);
+ hal_ctx = driverState->privateData;
VIR_INFO0("Creating new objects");
dbus_error_init(&err);
udi = libhal_get_all_devices(hal_ctx, &num_devs, &err);
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index fb30c37..c492341 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -63,8 +63,6 @@
#define VIR_FROM_THIS VIR_FROM_OPENVZ
#define OPENVZ_MAX_ARG 28
-#define CMDBUF_LEN 1488
-#define CMDOP_LEN 288
static int openvzGetProcessInfo(unsigned long long *cpuTime, int vpsid);
static int openvzGetMaxVCPUs(virConnectPtr conn, const char *type);
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 168c60f..2208573 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -43,9 +43,6 @@
#define VIR_FROM_THIS VIR_FROM_QEMU
-#define QEMU_CMD_PROMPT "\n(qemu) "
-#define QEMU_PASSWD_PROMPT "Password: "
-
#define DEBUG_IO 0
/* Return -1 for error, 0 for success */
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index bf94e70..7f7687a 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -691,9 +691,6 @@ doRemoteOpen (virConnectPtr conn,
}
}
-# ifndef UNIX_PATH_MAX
-# define UNIX_PATH_MAX(addr) (sizeof (addr).sun_path)
-# endif
struct sockaddr_un addr;
int trials = 0;
diff --git a/src/security/security_stack.c b/src/security/security_stack.c
index 64f745a..5cdcc6a 100644
--- a/src/security/security_stack.c
+++ b/src/security/security_stack.c
@@ -24,8 +24,6 @@
#include "virterror_internal.h"
-#define VIR_FROM_THIS VIR_FROM_SECURITY
-
typedef struct _virSecurityStackData virSecurityStackData;
typedef virSecurityStackData *virSecurityStackDataPtr;
diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c
index 7c8fb16..909515f 100644
--- a/src/uml/uml_conf.c
+++ b/src/uml/uml_conf.c
@@ -52,8 +52,6 @@
#define VIR_FROM_THIS VIR_FROM_UML
-#define umlLog(level, msg, ...) \
- virLogMessage(__FILE__, level, 0, msg, __VA_ARGS__)
virCapsPtr umlCapsInit(void) {
struct utsname utsname;
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index e2bd5f2..a26087c 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -65,9 +65,6 @@
#define VIR_FROM_THIS VIR_FROM_UML
-/* For storing short-lived temporary files. */
-#define TEMPDIR LOCALSTATEDIR "/cache/libvirt"
-
typedef struct _umlDomainObjPrivate umlDomainObjPrivate;
typedef umlDomainObjPrivate *umlDomainObjPrivatePtr;
struct _umlDomainObjPrivate {
diff --git a/src/util/bridge.c b/src/util/bridge.c
index 3ed71be..00234df 100644
--- a/src/util/bridge.c
+++ b/src/util/bridge.c
@@ -52,9 +52,6 @@
# include "logging.h"
# include "network.h"
-# define JIFFIES_TO_MS(j) (((j)*1000)/HZ)
-# define MS_TO_JIFFIES(ms) (((ms)*HZ)/1000)
-
struct _brControl {
int fd;
};
diff --git a/src/util/hooks.c b/src/util/hooks.c
index 819c95c..3eeb698 100644
--- a/src/util/hooks.c
+++ b/src/util/hooks.c
@@ -42,7 +42,7 @@
#define VIR_FROM_THIS VIR_FROM_HOOK
#define virHookReportError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_HOOK, code, __FILE__, \
+ virReportErrorHelper(NULL, VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
#define LIBVIRT_HOOK_DIR SYSCONFDIR "/libvirt/hooks"
diff --git a/src/util/logging.c b/src/util/logging.c
index 9d18752..0330fec 100644
--- a/src/util/logging.c
+++ b/src/util/logging.c
@@ -44,8 +44,6 @@
#include "threads.h"
#include "files.h"
-#define VIR_FROM_THIS VIR_FROM_NONE
-
/*
* Macro used to format the message as a string in virLogMessage
* and borrowed from libxml2 (also used in virRaiseError)
diff --git a/src/util/macvtap.c b/src/util/macvtap.c
index 346eaf6..f563c23 100644
--- a/src/util/macvtap.c
+++ b/src/util/macvtap.c
@@ -71,8 +71,10 @@
# define MICROSEC_PER_SEC (1000 * 1000)
-# define NLMSGBUF_SIZE 256
-# define RATTBUF_SIZE 64
+# if 0
+# define NLMSGBUF_SIZE 256
+# define RATTBUF_SIZE 64
+# endif
# define NETLINK_ACK_TIMEOUT_S 2
diff --git a/src/util/pci.c b/src/util/pci.c
index 8d2dbb0..0e8cdee 100644
--- a/src/util/pci.c
+++ b/src/util/pci.c
@@ -96,7 +96,7 @@ struct _pciDeviceList {
#define PCI_HEADER_TYPE 0x0e /* Header type */
#define PCI_HEADER_TYPE_BRIDGE 0x1
#define PCI_HEADER_TYPE_MASK 0x7f
-#define PCI_HEADER_TYPE_MULTI 0x80
+/*#define PCI_HEADER_TYPE_MULTI 0x80*/
/* PCI30 6.2.1 Device Identification */
#define PCI_CLASS_DEVICE 0x0a /* Device class */
@@ -123,7 +123,7 @@ struct _pciDeviceList {
#define PCI_EXP_DEVCAP_FLR (1<<28) /* Function Level Reset */
/* Header type 1 BR12 3.2 PCI-to-PCI Bridge Configuration Space Header Format */
-#define PCI_PRIMARY_BUS 0x18 /* BR12 3.2.5.2 Primary bus number */
+/*#define PCI_PRIMARY_BUS 0x18*/ /* BR12 3.2.5.2 Primary bus number */
#define PCI_SECONDARY_BUS 0x19 /* BR12 3.2.5.3 Secondary bus number */
#define PCI_SUBORDINATE_BUS 0x1a /* BR12 3.2.5.4 Highest bus number behind the bridge */
#define PCI_BRIDGE_CONTROL 0x3e
diff --git a/src/util/storage_file.c b/src/util/storage_file.c
index ede79fa..c427054 100644
--- a/src/util/storage_file.c
+++ b/src/util/storage_file.c
@@ -101,7 +101,9 @@ qedGetBackingStore(char **, int *, const unsigned char *, size_t);
#define QCOW1_HDR_CRYPT (QCOWX_HDR_IMAGE_SIZE+8+1+1)
#define QCOW2_HDR_CRYPT (QCOWX_HDR_IMAGE_SIZE+8)
-#define QCOW1_HDR_TOTAL_SIZE (QCOW1_HDR_CRYPT+4+8)
+#if 0
+# define QCOW1_HDR_TOTAL_SIZE (QCOW1_HDR_CRYPT+4+8)
+#endif
#define QCOW2_HDR_TOTAL_SIZE (QCOW2_HDR_CRYPT+4+4+8+8+4+4+8)
#define QCOW2_HDR_EXTENSION_END 0
diff --git a/src/vbox/vbox_driver.c b/src/vbox/vbox_driver.c
index 9526ee4..6e680ba 100644
--- a/src/vbox/vbox_driver.c
+++ b/src/vbox/vbox_driver.c
@@ -42,8 +42,6 @@
#include "virterror_internal.h"
#include "util.h"
-#define VIR_FROM_THIS VIR_FROM_VBOX
-
extern virDriver vbox22Driver;
extern virNetworkDriver vbox22NetworkDriver;
@@ -66,7 +64,7 @@ static virDriver vboxDriverDummy;
#define VIR_FROM_THIS VIR_FROM_VBOX
#define vboxError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_VBOX, code, __FILE__, \
+ virReportErrorHelper(NULL, VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
int vboxRegister(void) {
diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c
index 8a9dae5..d7d74a4 100644
--- a/src/xen/xen_hypervisor.c
+++ b/src/xen/xen_hypervisor.c
@@ -80,16 +80,12 @@ typedef struct v0_hypercall_struct {
} v0_hypercall_t;
#ifdef __linux__
-# define XEN_V0_IOCTL_HYPERCALL_CMD \
- _IOC(_IOC_NONE, 'P', 0, sizeof(v0_hypercall_t))
/* the new one */
typedef struct v1_hypercall_struct
{
uint64_t op;
uint64_t arg[5];
} v1_hypercall_t;
-# define XEN_V1_IOCTL_HYPERCALL_CMD \
- _IOC(_IOC_NONE, 'P', 0, sizeof(v1_hypercall_t))
typedef v1_hypercall_t hypercall_t;
#elif defined(__sun)
typedef privcmd_hypercall_t hypercall_t;
@@ -140,8 +136,6 @@ static regex_t xen_cap_rec;
# define DOMFLAGS_PAUSED (1<<3) /* Currently paused by control software. */
# define DOMFLAGS_BLOCKED (1<<4) /* Currently blocked pending an event. */
# define DOMFLAGS_RUNNING (1<<5) /* Domain is currently running. */
-# define DOMFLAGS_CPUMASK 255 /* CPU to which this domain is bound. */
-# define DOMFLAGS_CPUSHIFT 8
# define DOMFLAGS_SHUTDOWNMASK 255 /* DOMFLAGS_SHUTDOWN guest-supplied code. */
# define DOMFLAGS_SHUTDOWNSHIFT 16
#endif
@@ -2709,13 +2703,13 @@ xenHypervisorMakeCapabilities(virConnectPtr conn)
}
}
- capabilities = fopen ("/sys/hypervisor/properties/capabilities", "r");
+ capabilities = fopen(HYPERVISOR_CAPABILITIES, "r");
if (capabilities == NULL) {
if (errno != ENOENT) {
VIR_FORCE_FCLOSE(cpuinfo);
virReportSystemError(errno,
_("cannot read file %s"),
- "/sys/hypervisor/properties/capabilities");
+ HYPERVISOR_CAPABILITIES);
return NULL;
}
}
@@ -3175,7 +3169,9 @@ xenHypervisorGetDomInfo(virConnectPtr conn, int id, virDomainInfoPtr info)
break;
case DOMFLAGS_SHUTDOWN:
/* The domain is shutdown. Determine the cause. */
- domain_shutdown_cause = domain_flags >> DOMFLAGS_SHUTDOWNSHIFT;
+ domain_shutdown_cause =
+ (domain_flags >> DOMFLAGS_SHUTDOWNSHIFT) &
+ DOMFLAGS_SHUTDOWNMASK;
switch (domain_shutdown_cause) {
case SHUTDOWN_crash:
info->state = VIR_DOMAIN_CRASHED;
diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index 7f73588..6c43811 100644
--- a/src/xen/xm_internal.c
+++ b/src/xen/xm_internal.c
@@ -52,14 +52,6 @@
#define VIR_FROM_THIS VIR_FROM_XENXM
-#ifdef WITH_RHEL5_API
-# define XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU 0
-# define XEND_CONFIG_MIN_VERS_PVFB_NEWCONF 2
-#else
-# define XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU 3
-# define XEND_CONFIG_MIN_VERS_PVFB_NEWCONF 3
-#endif
-
/* The true Xen limit varies but so far is always way
less than 1024, which is the Linux kernel limit according
to sched.h, so we'll match that for now */
@@ -78,7 +70,6 @@ static int xenXMDomainDetachDeviceFlags(virDomainPtr domain, const char *xml,
#define XEND_CONFIG_FILE "xend-config.sxp"
#define XEND_PCI_CONFIG_PREFIX "xend-pci-"
#define QEMU_IF_SCRIPT "qemu-ifup"
-#define XM_XML_ERROR "Invalid xml"
struct xenUnifiedDriver xenXMDriver = {
xenXMOpen, /* open */
diff --git a/tests/sockettest.c b/tests/sockettest.c
index 2c9ff03..bb44496 100644
--- a/tests/sockettest.c
+++ b/tests/sockettest.c
@@ -170,16 +170,6 @@ mymain(int argc ATTRIBUTE_UNUSED,
if (!virTestGetDebug())
virSetErrorFunc(NULL, testQuietError);
-#define DO_TEST_PARSE(addrstr, family, pass) \
- do { \
- virSocketAddr addr; \
- struct testParseData data = { &addr, addrstr, family, pass }; \
- memset(&addr, 0, sizeof(addr)); \
- if (virtTestRun("Test parse " addrstr, \
- 1, testParseHelper, &data) < 0) \
- ret = -1; \
- } while (0)
-
#define DO_TEST_PARSE_AND_FORMAT(addrstr, family, pass) \
do { \
virSocketAddr addr; \
diff --git a/tools/virsh.c b/tools/virsh.c
index 4765f5c..d1c3fe3 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -80,12 +80,12 @@ static char *progname;
*/
#define MSG_BUFFER 4096
#define SIGN_NAME "virsh"
-#define DIR_MODE (S_IWUSR | S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) /* 0755 */
#define FILE_MODE (S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH) /* 0644 */
-#define LOCK_MODE (S_IWUSR | S_IRUSR) /* 0600 */
#define LVL_DEBUG "DEBUG"
#define LVL_INFO "INFO"
+#if 0
#define LVL_NOTICE "NOTICE"
+#endif
#define LVL_WARNING "WARNING"
#define LVL_ERROR "ERROR"
@@ -409,15 +409,6 @@ _vshStrdup(vshControl *ctl, const char *s, const char *filename, int line)
exit(EXIT_FAILURE);
}
-/* Poison the raw allocating identifiers in favor of our vsh variants. */
-#undef malloc
-#undef calloc
-#undef realloc
-#undef strdup
-#define malloc use_vshMalloc_instead_of_malloc
-#define calloc use_vshCalloc_instead_of_calloc
-#define realloc use_vshRealloc_instead_of_realloc
-#define strdup use_vshStrdup_instead_of_strdup
static int idsorter(const void *a, const void *b) {
const int *ia = (const int *)a;
--
1.7.4
From berrange at redhat.com Mon Apr 4 16:28:52 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 17:28:52 +0100
Subject: [libvirt] [PATCH] Use gnulib's manywarnings & warnings modules
In-Reply-To: <4D95F70A.80509@redhat.com>
References: <1301672345-31926-1-git-send-email-berrange@redhat.com>
<4D95F70A.80509@redhat.com>
Message-ID: <20110404162852.GF13616@redhat.com>
On Fri, Apr 01, 2011 at 10:02:18AM -0600, Eric Blake wrote:
> On 04/01/2011 09:39 AM, Daniel P. Berrange wrote:
> >
> > * acinclude.m4: Rewrite to use gl_WARN_ADD and gl_MANYWARN_ALL_GCC
> > * bootstrap.conf: Add warnings & manywarnings
> > * configure.ac: Switch to gl_WARN_ADD
> > * m4/compiler-flags.m4: Obsoleted by gl_WARN_ADD
> > ---
> > acinclude.m4 | 153 ++++++++++++++++++++++++++------------------------
>
> I really don't like how we have crammed so much into acinclude.m4; it
> would be nicer if we could separate things into individual m4/foo.m4
> files...
The new series moves this file
> > + # List of warnings that are not relevant / wanted
> > + dontwarn="$dontwarn -Wc++-compat" # Don't care about C++ compiler compat
> > + dontwarn="$dontwarn -Wtraditional" # Don't care about ancient C standard compat
> > + dontwarn="$dontwarn -Wtraditional-conversion" # Don't care about ancient C standard compat
> > + dontwarn="$dontwarn -Wsystem-headers" # Ignore warnings in /usr/include
> > + dontwarn="$dontwarn -Wpadded" # Happy for compiler to add struct padding
> > + dontwarn="$dontwarn -Wunreachable-code" # GCC very confused with -O2
> > + dontwarn="$dontwarn -Wconversion" # Too many to deal with
> > + dontwarn="$dontwarn -Wsign-conversion" # Too many to deal with
> > + dontwarn="$dontwarn -Wvla" # GNULIB gettext.h violates
> > + dontwarn="$dontwarn -Wundef" # Many GNULIB violations
>
> We really ought to follow coreutils' lead of generating two separate
> lists of -W flags - a larger set for libvirt and a smaller set for
> gnulib. Then exemptions such as -Wvla could be used just for gnulib.
> But that can be a followup patch.
The problem isn't with the compilation of gnulib - that doesn't use
any of these flags. The issue is with various things in the gnulib
header files, which impact compilation of the main libvirt code.
eg
../gnulib/lib/gettext.h:218:3: error: variable length array 'msg_ctxt_id' is used [-Wvla]
>
> > + dontwarn="$dontwarn -Wcast-qual" # Need to allow bad cast for execve()
> > + dontwarn="$dontwarn -Wlong-long" # We need to use long long in many places
> > +
> > + # We might fundamentally need some of these disabled forever, but ideally
> > + # we'd turn many of them on
> > + dontwarn="$dontwarn -Wformat-nonliteral"
> > + dontwarn="$dontwarn -Wswitch-default"
> > + dontwarn="$dontwarn -Wswitch-enum"
> > + dontwarn="$dontwarn -Wstrict-overflow"
> > + dontwarn="$dontwarn -Wfloat-equal"
> > + dontwarn="$dontwarn -Wdeclaration-after-statement"
> > + dontwarn="$dontwarn -Wunsafe-loop-optimizations"
> > + dontwarn="$dontwarn -Wcast-qual"
> > + dontwarn="$dontwarn -Wconversion"
> > + dontwarn="$dontwarn -Wsign-conversion"
> > + dontwarn="$dontwarn -Wold-style-definition"
> > + dontwarn="$dontwarn -Wmissing-noreturn"
> > + dontwarn="$dontwarn -Wpacked"
> > + dontwarn="$dontwarn -Wunused-macros"
> > + dontwarn="$dontwarn -W"
>
> -W is the same as -Wextra - that turns on a lot of useful warnings. Can
> we fine-tune it to just disable the needed warnings?
Removing that means I need a manual check for -Wno-sign-compare
since gl_MANYWAY_COMPLEMENT can't see that -W include -Wsign-compare
>
> > + dontwarn="$dontwarn -Woverlength-strings"
> > + dontwarn="$dontwarn -Wmissing-format-attribute"
> > + dontwarn="$dontwarn -Wstack-protector"
> > +
> > + # Get all possible GCC warnings
> > + gl_MANYWARN_ALL_GCC([maybewarn])
> > +
> > + # Remove the ones we don't want, blacklisted earlier
> > + gl_MANYWARN_COMPLEMENT([wantwarn], [$maybewarn], [$dontwarn])
> > +
> > + # Check for $CC support of each warning
> > + for w in $wantwarn; do
> > + gl_WARN_ADD([$w])
> > + done
>
> Yep, gnulib's macros are nice for this!
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From blauwirbel at gmail.com Mon Apr 4 16:38:51 2011
From: blauwirbel at gmail.com (Blue Swirl)
Date: Mon, 4 Apr 2011 19:38:51 +0300
Subject: [libvirt] [Qemu-devel] [PATCH v2 3/3] raw-posix: Re-open host
CD-ROM after media change
In-Reply-To: <4D99D920.1040800@codemonkey.ws>
References: <1301425482-8722-1-git-send-email-stefanha@linux.vnet.ibm.com>
<1301425482-8722-4-git-send-email-stefanha@linux.vnet.ibm.com>
<20110404104753.GX13616@redhat.com>
<4D99C162.7060706@us.ibm.com> <20110404131639.GB13616@redhat.com>
<4D99D378.8030206@us.ibm.com> <20110404142612.GD13616@redhat.com>
<4D99D920.1040800@codemonkey.ws>
Message-ID:
On Mon, Apr 4, 2011 at 5:43 PM, Anthony Liguori wrote:
> On 04/04/2011 09:26 AM, Daniel P. Berrange wrote:
>>
>> On Mon, Apr 04, 2011 at 09:19:36AM -0500, Anthony Liguori wrote:
>>>
>>> On 04/04/2011 08:16 AM, Daniel P. Berrange wrote:
>>>>
>>>> That doesn't really have any impact. If a desktop user is logged
>>>> in, udev may change the ownership to match that user, but if they
>>>> aren't, then udev may reset it to root:disk. Either way, QEMU
>>>> may loose permissions to the disk.
>>>
>>> Then if you create a guest without being in the 'disk' group, it'll
>>> fail. ?That's pretty expected AFAICT.
>>
>> We don't *ever* want to put QEMU in the 'disk' group because
>> that gives it access to any disk on the system in general.
>
> If that's what the user wants to do, what's the problem with doing it?
>
> Setting the global user/group is not enough because just because you have
> one VM that you want in disk doesn't mean you want all of them in disk.
Privilege separated QEMU sounds so interesting that I'd go for that
direction. There could be helper processes which retain privileges and
communicate with the main unprivileged QEMU with only file
descriptors. The helpers could even execute setgid disk group
re-opener for the CD-ROM case, or ask libvirt to do the reopen. For
unprivileged QEMU part it wouldn't matter, all it sees are the
descriptors.
From berrange at redhat.com Mon Apr 4 16:59:50 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Mon, 4 Apr 2011 17:59:50 +0100
Subject: [libvirt] [PATCH v2] Improve SCSI volume key generation
Message-ID: <1301936390-14887-1-git-send-email-berrange@redhat.com>
An update of patch 10 from:
http://www.redhat.com/archives/libvir-list/2010-November/msg00555.html
The SCSI volumes get a better 'key' field based on the fully
qualified volume path. All SCSI volumes have a unique serial
available in hardware which can be obtained by sending a
suitable SCSI command. Call out to udev's 'scsi_id' command
to fetch this value
In v2:
- Only use scsi_id if HAVE_UDEV is defined. This ensures
use only on udev >= 145 and thus avoids problem of
different semantics on RHEL-5 vintage udev
- Use virCommandPtr instead of virExec
- Use VIR_FDOPEN instead of fdopen
* src/storage/storage_backend_scsi.c: Improve volume key
field value stability and uniqueness
---
src/storage/storage_backend_scsi.c | 65 +++++++++++++++++++++++++++++++++--
1 files changed, 61 insertions(+), 4 deletions(-)
diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c
index d880d65..ed91703 100644
--- a/src/storage/storage_backend_scsi.c
+++ b/src/storage/storage_backend_scsi.c
@@ -33,6 +33,7 @@
#include "memory.h"
#include "logging.h"
#include "files.h"
+#include "command.h"
#define VIR_FROM_THIS VIR_FROM_STORAGE
@@ -160,6 +161,65 @@ cleanup:
return ret;
}
+
+static char *
+virStorageBackendSCSISerial(const char *dev)
+{
+ char *serial = NULL;
+#ifdef HAVE_UDEV
+ int fd = -1;
+ FILE *list = NULL;
+ char line[1024];
+ virCommandPtr cmd = virCommandNewArgList(
+ "/lib/udev/scsi_id",
+ "--replace-whitespace",
+ "--whitelisted",
+ "--device", dev,
+ NULL
+ );
+
+ /* Run the program and capture its output */
+ virCommandSetOutputFD(cmd, &fd);
+ if (virCommandRunAsync(cmd, NULL) < 0)
+ goto cleanup;
+
+ if ((list = VIR_FDOPEN(fd, "r")) == NULL) {
+ virStorageReportError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("cannot read fd"));
+ goto cleanup;
+ }
+
+ if (fgets(line, sizeof(line), list)) {
+ char *nl = strchr(line, '\n');
+ if (nl)
+ *nl = '\0';
+ VIR_ERROR("GOT ID %s\n", line);
+ serial = strdup(line);
+ } else {
+ VIR_ERROR("NO ID %s\n", dev);
+ serial = strdup(dev);
+ }
+
+ if (!serial) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+cleanup:
+ if (list)
+ fclose(list);
+ else
+ VIR_FORCE_CLOSE(fd);
+
+ virCommandFree(cmd);
+#else
+ if (!(serial = strdup(dev)))
+ virReportOOMError();
+#endif
+ return serial;
+}
+
+
static int
virStorageBackendSCSINewLun(virStoragePoolObjPtr pool,
uint32_t host ATTRIBUTE_UNUSED,
@@ -233,10 +293,7 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool,
goto free_vol;
}
- /* XXX should use logical unit's UUID instead */
- vol->key = strdup(vol->target.path);
- if (vol->key == NULL) {
- virReportOOMError();
+ if (!(vol->key = virStorageBackendSCSISerial(vol->target.path))) {
retval = -1;
goto free_vol;
}
--
1.7.4
From eblake at redhat.com Mon Apr 4 17:12:17 2011
From: eblake at redhat.com (Eric Blake)
Date: Mon, 04 Apr 2011 11:12:17 -0600
Subject: [libvirt] [PATCH v2] Improve SCSI volume key generation
In-Reply-To: <1301936390-14887-1-git-send-email-berrange@redhat.com>
References: <1301936390-14887-1-git-send-email-berrange@redhat.com>
Message-ID: <4D99FBF1.5000003@redhat.com>
On 04/04/2011 10:59 AM, Daniel P. Berrange wrote:
> An update of patch 10 from:
>
> http://www.redhat.com/archives/libvir-list/2010-November/msg00555.html
>
> The SCSI volumes get a better 'key' field based on the fully
> qualified volume path. All SCSI volumes have a unique serial
> available in hardware which can be obtained by sending a
> suitable SCSI command. Call out to udev's 'scsi_id' command
> to fetch this value
>
> +static char *
> +virStorageBackendSCSISerial(const char *dev)
> +{
> + char *serial = NULL;
> +#ifdef HAVE_UDEV
> + int fd = -1;
> + FILE *list = NULL;
> + char line[1024];
> + virCommandPtr cmd = virCommandNewArgList(
> + "/lib/udev/scsi_id",
> + "--replace-whitespace",
> + "--whitelisted",
> + "--device", dev,
> + NULL
> + );
> +
> + /* Run the program and capture its output */
> + virCommandSetOutputFD(cmd, &fd);
Why not just run virCommandSetOutputBuffer, to capture the entire output
into a single string...
> + if (virCommandRunAsync(cmd, NULL) < 0)
> + goto cleanup;
...then you just use virCommandRun,
> +
> + if ((list = VIR_FDOPEN(fd, "r")) == NULL) {
...you don't have to mess with fdopen,
> + virStorageReportError(VIR_ERR_INTERNAL_ERROR,
> + "%s", _("cannot read fd"));
> + goto cleanup;
> + }
> +
> + if (fgets(line, sizeof(line), list)) {
...and you don't have to mess with fgets,
> +cleanup:
> + if (list)
> + fclose(list);
and your cleanup gets a lot easier (not to mention that 'make
syntax-check' should have been telling you to use VIR_FORCE_FCLOSE if
you don't make those simplifications).
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From eblake at redhat.com Mon Apr 4 17:28:23 2011
From: eblake at redhat.com (Eric Blake)
Date: Mon, 04 Apr 2011 11:28:23 -0600
Subject: [libvirt] [PATCH] build: detect potentential uninitialized
variables
In-Reply-To:
References: <1301673022-7410-1-git-send-email-eblake@redhat.com>
Message-ID: <4D99FFB7.7010005@redhat.com>
On 04/02/2011 12:15 AM, Matthias Bolte wrote:
>> which prints 0 (if the stack was previously wiped) if cond
>> was true. Clang will catch it, but we dont' use clang as
>> often. Using gcc -Wjump-misses-init gives false positives:
>>
>
> ACK.
Thanks; pushed.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From eblake at redhat.com Mon Apr 4 17:30:42 2011
From: eblake at redhat.com (Eric Blake)
Date: Mon, 04 Apr 2011 11:30:42 -0600
Subject: [libvirt] [PATCH] vmx: Support persistent CPU shares
In-Reply-To:
References: <20110403124355.GA22943@sbox> <20110404030541.GQ24385@redhat.com>
Message-ID: <4D9A0042.8030805@redhat.com>
On 04/04/2011 12:28 AM, Matthias Bolte wrote:
> 2011/4/4 Daniel Veillard :
>> On Sun, Apr 03, 2011 at 02:43:55PM +0200, Matthias Bolte wrote:
>
>>
>> ACK, while nice, it may be a bit late for 0.9.0, okay to wait for the
>> next cycle ? We already have this for xen and qemu, seeing it for ESX
>> confirms the design is fine, which is the most important from my point
>> of vue :-)
>>
>> Daniel
>>
>
> Sure, this can wait until 0.9.1. On the ESX side the shares value is
> persistent anyway. This patch just exposes it as persistent in libvirt
> too.
0.9.1 is now started, so feel free to push now :)
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From dallan at redhat.com Mon Apr 4 18:24:37 2011
From: dallan at redhat.com (Dave Allan)
Date: Mon, 4 Apr 2011 14:24:37 -0400
Subject: [libvirt] [PATCH] qemu: Don't fail driver startup with ancient
qemu
In-Reply-To: <20110404133732.GH389283@orkuz.home>
References: <2e1f2e4705bb467bcf237647706555bf4e97ec1e.1301923139.git.jdenemar@redhat.com>
<20110404132359.GC13616@redhat.com>
<20110404133732.GH389283@orkuz.home>
Message-ID: <20110404182437.GD4156@redhat.com>
On Mon, Apr 04, 2011 at 03:37:32PM +0200, Jiri Denemark wrote:
> On Mon, Apr 04, 2011 at 14:23:59 +0100, Daniel P. Berrange wrote:
> > On Mon, Apr 04, 2011 at 03:18:59PM +0200, Jiri Denemark wrote:
> > > Failure to extract version info (e.g., because qemu binary is so ancient
> > > that it doesn't even support -help) shouldn't be considered fatal since
> > > we only need it to detect whether qemu supports bootindex option.
> > > ---
> > > src/qemu/qemu_capabilities.c | 7 ++++---
> > > 1 files changed, 4 insertions(+), 3 deletions(-)
> >
> > What version QEMU doesn't support -help ?
> >
> > We only aim to work with QEMU >= 0.9.0 and I'm fairly sure
> > that has -help support.
>
> An ancient one, 0.6.0. But that was just an example. Extracting version info
> may fail for a bunch of reasons. The main thing is that it shouldn't fail qemu
> driver startup since that results in libvirtd startup failure.
Why does driver startup failure result in libvirtd startup failure?
Shouldn't it only result in the lack of availability of the driver?
Dave
From dsahern at gmail.com Mon Apr 4 17:54:25 2011
From: dsahern at gmail.com (David Ahern)
Date: Mon, 04 Apr 2011 11:54:25 -0600
Subject: [libvirt] [Qemu-devel] [PATCH v2 3/3] raw-posix: Re-open host
CD-ROM after media change
In-Reply-To: <4D99C9ED.3020602@codemonkey.ws>
References: <1301425482-8722-1-git-send-email-stefanha@linux.vnet.ibm.com> <1301425482-8722-4-git-send-email-stefanha@linux.vnet.ibm.com> <4D99C61E.3080600@redhat.com>
<4D99C9ED.3020602@codemonkey.ws>
Message-ID: <4D9A05D1.1000501@gmail.com>
On 04/04/11 07:38, Anthony Liguori wrote:
> On 04/04/2011 08:22 AM, Avi Kivity wrote:
>> On 04/03/2011 02:57 PM, Stefan Hajnoczi wrote:
>>> In order for media change to work with Linux host CD-ROM it is
>>> necessary to reopen the file (otherwise the inode size will not
>>> refresh, this is an issue with existing kernels).
>>>
>>
>> Maybe we should fix the bug in Linux (and backport as necessary)?
>>
>> I think cd-rom assignment is sufficiently obscure that we can require
>> a fixed kernel instead of providing a workaround.
>
> Do reads fail after CD change? Or do they succeed and the size is just
> reported incorrectly?
>
> If it's the later, I'd agree that it needs fixing in the kernel. If
> it's the former, I'd say it's clearly a feature.
In January 2010 I was seeing old data -- data from the prior CD -- in
the guest after the media change.
David
From eblake at redhat.com Mon Apr 4 19:31:40 2011
From: eblake at redhat.com (Eric Blake)
Date: Mon, 04 Apr 2011 13:31:40 -0600
Subject: [libvirt] [PATCH] Allow handshake with child process during
startup
In-Reply-To: <1301921731-32248-1-git-send-email-berrange@redhat.com>
References: <1301921731-32248-1-git-send-email-berrange@redhat.com>
Message-ID: <4D9A1C9C.3020501@redhat.com>
On 04/04/2011 06:55 AM, Daniel P. Berrange wrote:
> Allow the parent process to perform a bi-directional handshake
> with the child process during fork/exec. The child process
> will fork and do its initial setup. Immediately prior to the
> exec(), it will stop & wait for a handshake from the parent
> process. The parent process will spawn the child and wait
> until the child reaches the handshake point. It will do
> whatever extra setup work is required, before signalling the
> child to continue.
>
> The implementation of this is done using two pairs of blocking
> pipes. The first pair is used to block the parent, until the
> child writes a single byte. Then the second pair pair is used
> to block the child, until the parent confirms with another
> single byte.
How worried are we about the child not doing any async-unsafe actions if
it wishes to avoid deadlock? We've already previously identified this
as a bug (such as in our handling of malloc in the child), but it's
somewhat of a corner-case, and I'm not sure how invasive it will be to
fix properly; so I am okay if a fixed version of this patch goes in
while we still leave that larger issue open for thought.
> +++ b/src/util/command.c
> @@ -35,6 +35,11 @@
> #include "files.h"
> #include "buf.h"
>
> +#include
> +#include
"internal.h" guaranteed this one for us.
> +#include
> +#include
Why do we need this one? We're already using WIFEXITED and friends
without explicitly needing this header.
> @@ -1115,7 +1129,6 @@ virCommandRun(virCommandPtr cmd, int *exitstatus)
> return ret;
> }
>
> -
> /*
> * Perform all virCommand-specific actions, along with the user hook.
> */
Spurious whitespace change?
> @@ -1125,12 +1138,61 @@ virCommandHook(void *data)
> virCommandPtr cmd = data;
> int res = 0;
>
> - if (cmd->hook)
> + if (cmd->hook) {
> + VIR_DEBUG("Run hook %p %p", cmd->hook, cmd->opaque);
> res = cmd->hook(cmd->opaque);
> + VIR_DEBUG("Done hook %d", res);
This adds yet more calls to malloc() inside the child,
> + }
> if (res == 0 && cmd->pwd) {
> VIR_DEBUG("Running child in %s", cmd->pwd);
...but no worse than what we've already been doing. If VIR_DEBUG were
the only use of malloc() in the child, then it could just boil down to
conditionally compiling VIR_DEBUG statements where they can be turned on
for debugging the implementation, but compiled out later to avoid
deadlock (at least, I'm assuming that VIR_DEBUG uses malloc() to format
a timestamp prior to the message when posting to the circular buffer).
> res = chdir(cmd->pwd);
> + if (res < 0) {
> + virReportSystemError(errno,
> + _("Unable to change to %s"), cmd->pwd);
> + }
> + }
> + if (cmd->handshake) {
> + char c = res < 0 ? '0' : '1';
> + int rv;
> + VIR_DEBUG("Notifying parent for handshake start on %d", cmd->handshakeWait[1]);
> + if (safewrite(cmd->handshakeWait[1], &c, sizeof(c)) != sizeof(c)) {
Since c is char, sizeof(c) == 1 by definition. But I'm okay with you
spelling out the longer form.
> + virReportSystemError(errno, "%s", _("Unable to notify parent process"));
> + return -1;
> + }
> +
> + /* On failure we pass the error message back to parent,
> + * so they don't have to dig through stderr logs
> + */
> + if (res < 0) {
> + virErrorPtr err = virGetLastError();
> + const char *msg = err ? err->message :
> + _("Unknown failure during hook execution");
Hmm, now that's a lot more use of malloc(), and not just in VIR_DEBUG()
calls.
> +
> +void virCommandRequireHandshake(virCommandPtr cmd)
> +{
> + if (pipe(cmd->handshakeWait) < 0) {
NULL dereference if cmd had a previous failure. You need to guard with:
if (!cmd || cmd->has_error) return;
> +
> +int virCommandHandshakeWait(virCommandPtr cmd)
> +{
> + char c;
> + int rv;
> + VIR_DEBUG("Wait for handshake on %d", cmd->handshakeWait[0]);
Likewise.
> +
> +int virCommandHandshakeNotify(virCommandPtr cmd)
> +{
> + char c = '1';
> + VIR_DEBUG("Notify handshake on %d", cmd->handshakeWait[0]);
Likewise.
> +++ b/src/util/command.h
> @@ -274,6 +274,11 @@ int virCommandRunAsync(virCommandPtr cmd,
> int virCommandWait(virCommandPtr cmd,
> int *exitstatus) ATTRIBUTE_RETURN_CHECK;
>
> +void virCommandRequireHandshake(virCommandPtr cmd);
> +
> +int virCommandHandshakeWait(virCommandPtr cmd);
> +int virCommandHandshakeNotify(virCommandPtr cmd);
These last two could use ATTRIBUTE_RETURN_CHECK. All three could use
documentation.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From eblake at redhat.com Mon Apr 4 19:49:04 2011
From: eblake at redhat.com (Eric Blake)
Date: Mon, 04 Apr 2011 13:49:04 -0600
Subject: [libvirt] [PATCH] qemu: Rewrite LOOKUP_PTYS macro into a
function
In-Reply-To: <6583e184fb3f616c15ec4bc42f1af58fff320a8b.1301924390.git.jdenemar@redhat.com>
References: <6583e184fb3f616c15ec4bc42f1af58fff320a8b.1301924390.git.jdenemar@redhat.com>
Message-ID: <4D9A20B0.6070405@redhat.com>
On 04/04/2011 07:46 AM, Jiri Denemark wrote:
> The macro is huge and gives us nothing but headache when maintaining it.
> ---
> The reason for this patch is not that I'm going to modify anything in
> the code. It's that I was working in the area and noticed this huge
> macro.
>
> src/qemu/qemu_process.c | 102 ++++++++++++++++++++++++++++-------------------
> 1 files changed, 61 insertions(+), 41 deletions(-)
The diffstat hides the fact that this really is a code cleanup.
ACK.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From eblake at redhat.com Mon Apr 4 20:29:06 2011
From: eblake at redhat.com (Eric Blake)
Date: Mon, 04 Apr 2011 14:29:06 -0600
Subject: [libvirt] [PATCH 1/6] Use gnulib's manywarnings & warnings
modules
In-Reply-To: <1301934004-6204-2-git-send-email-berrange@redhat.com>
References: <1301934004-6204-1-git-send-email-berrange@redhat.com>
<1301934004-6204-2-git-send-email-berrange@redhat.com>
Message-ID: <4D9A2A12.3010401@redhat.com>
On 04/04/2011 10:19 AM, Daniel P. Berrange wrote:
> Remove custom code for checking compiler warnings, using
> gl_WARN_ADD instead. Don't list all flags ourselves, use
> gnulib's gl_MANYWARN_ALL_GCC to get all possible GCC flags,
> then turn off the ones we don't want yet.
>
> * acinclude.m4: Rewrite to use gl_WARN_ADD and gl_MANYWARN_ALL_GCC
> * bootstrap.conf: Add warnings & manywarnings
> * configure.ac: Switch to gl_WARN_ADD
> * m4/compiler-flags.m4: Obsoleted by gl_WARN_ADD
> ---
> acinclude.m4 | 158 +++++++++++++++++++++++++++-----------------------
> bootstrap.conf | 2 +
> configure.ac | 15 +++--
> m4/compiler-flags.m4 | 48 ---------------
> 4 files changed, 96 insertions(+), 127 deletions(-)
> delete mode 100644 m4/compiler-flags.m4
> +
> + # List of warnings that are not relevant / wanted
> + dontwarn="$dontwarn -Wc++-compat" # Don't care about C++ compiler compat
> + dontwarn="$dontwarn -Wtraditional" # Don't care about ancient C standard compat
> + dontwarn="$dontwarn -Wtraditional-conversion" # Don't care about ancient C standard compat
> + dontwarn="$dontwarn -Wsystem-headers" # Ignore warnings in /usr/include
> + dontwarn="$dontwarn -Wpadded" # Happy for compiler to add struct padding
> + dontwarn="$dontwarn -Wunreachable-code" # GCC very confused with -O2
> + dontwarn="$dontwarn -Wconversion" # Too many to deal with
> + dontwarn="$dontwarn -Wsign-conversion" # Too many to deal with
> + dontwarn="$dontwarn -Wvla" # GNULIB gettext.h violates
> + dontwarn="$dontwarn -Wundef" # Many GNULIB violations
> + dontwarn="$dontwarn -Wcast-qual" # Need to allow bad cast for execve()
> + dontwarn="$dontwarn -Wlong-long" # We need to use long long in many places
> + dontwarn="$dontwarn -Wswitch-default" # We allow manual list of all enum cases without default:
> + dontwarn="$dontwarn -Wswitch-enum" # We allow optional default: instead of listing all enum values
> + dontwarn="$dontwarn -Wstrict-overflow" # Not a problem since we don't use -fstrict-overflow
> + dontwarn="$dontwarn -Wunsafe-loop-optimizations" # Not a problem since we don't use -funsafe-loop-optimizations
Seems okay (but long lines - any way to break that into 80 columns?)
> +
> + # We might fundamentally need some of these disabled forever, but ideally
> + # we'd turn many of them on
> + dontwarn="$dontwarn -Wformat-nonliteral"
This one may need to always be disabled, thanks to virAsprintf (it would
be nicer if we could disable for just one or two files, rather than
globally).
> + dontwarn="$dontwarn -Wfloat-equal"
> + dontwarn="$dontwarn -Wdeclaration-after-statement"
If gcc would do better, I'd love to guarantee C99 and take advantage of
this (smaller scopes have maintenance benefits) - thus, I envision this
one being permanent (float it up to the earlier set).
> + dontwarn="$dontwarn -Wcast-qual"
> + dontwarn="$dontwarn -Wconversion"
> + dontwarn="$dontwarn -Wsign-conversion"
> + dontwarn="$dontwarn -Wold-style-definition"
> + dontwarn="$dontwarn -Wmissing-noreturn"
> + dontwarn="$dontwarn -Wpacked"
> + dontwarn="$dontwarn -Wunused-macros"
> + dontwarn="$dontwarn -Woverlength-strings"
> + dontwarn="$dontwarn -Wmissing-format-attribute"
> + dontwarn="$dontwarn -Wstack-protector"
Yes, I agree that the rest of these should be temporary, and are
probably worth fixing.
> +
> + # Get all possible GCC warnings
> + gl_MANYWARN_ALL_GCC([maybewarn])
> +
> + # Remove the ones we don't want, blacklisted earlier
> + gl_MANYWARN_COMPLEMENT([wantwarn], [$maybewarn], [$dontwarn])
> +
> + # Check for $CC support of each warning
> + for w in $wantwarn; do
> + gl_WARN_ADD([$w])
> + done
> +
> + # GNULIB uses '-W' which includes a bunch of stuff,
> + # kinda like -Wextra. Unfortunately, it means you
"kinda like"? Exactly like! -W was the old spelling, -Wextra was the
new one (added quite some time ago; something like gcc 3.4, off the top
of my head).
> + # can't simply use '-Wsign-compare' with gl_MANYWARN_COMPLEMENT
> + # So we have -W enabled, and then have to explicitly turn off
> + gl_WARN_ADD(-Wno-sign-compare)
> +
> + # This should be < 256 really, but with PATH_MAX everywhere
> + # we have doom, even with 4096. In fact we have some functions
> + # with several PATH_MAX sized variables :-( We should kill off
> + # all PATH_MAX usage and then lower this limit
> + gl_WARN_ADD([-Wframe-larger-than=65700])
> + dnl gl_WARN_ADD([-Wframe-larger-than=4096])
> + dnl gl_WARN_ADD([-Wframe-larger-than=256])
> +
> + # Extra special flags
> + gl_WARN_ADD([-Wp,-D_FORTIFY_SOURCE=2])
> + dnl Fedora only uses -fstack-protector, but doesn't seem to
> + dnl be great overhead in adding -fstack-protector-all instead
> + dnl gl_WARN_ADD([-fstack-protector])
> + gl_WARN_ADD([-fstack-protector-all])
> + gl_WARN_ADD([--param=ssp-buffer-size=4])
> + gl_WARN_ADD([-fexceptions])
> + gl_WARN_ADD([-fasynchronous-unwind-tables])
> + gl_WARN_ADD([-fdiagnostics-show-option])
> +
> + if test "$enable_compile_warnings" = "error"
> + then
> + gl_WARN_ADD([-Werror])
> + fi
Looks like a good conversion.
> @@ -81,6 +82,7 @@ timegm
> uname
> useless-if-before-free
> usleep
> +warnings
> vasprintf
> verify
> vc-list-files
Where did you learn to sort? :)
> diff --git a/configure.ac b/configure.ac
> index a8d223a..7874c30 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -1970,12 +1970,14 @@ AC_ARG_ENABLE([test-coverage],
> enable_coverage=$enableval
>
> if test "${enable_coverage}" = yes; then
> - COMPILER_FLAGS=
> - gl_COMPILER_FLAGS(-fprofile-arcs)
> - gl_COMPILER_FLAGS(-ftest-coverage)
> - AC_SUBST([COVERAGE_CFLAGS], [$COMPILER_FLAGS])
> - AC_SUBST([COVERAGE_LDFLAGS], [$COMPILER_FLAGS])
> - COMPILER_FLAGS=
> + save_WARN_CFLAGS=$WARN_CFLAGS
> + WARN_CFLAGS=
> + gl_WARN_ADD(-fprofile-arcs)
> + gl_WARN_ADD(-ftest-coverage)
Nit: use consistent m4 quoting: gl_WARN_ADD([-fprofile-arcs])
ACK with nits addressed.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From eblake at redhat.com Mon Apr 4 20:37:00 2011
From: eblake at redhat.com (Eric Blake)
Date: Mon, 04 Apr 2011 14:37:00 -0600
Subject: [libvirt] [PATCH 2/6] Remove acinclude.m4 file
In-Reply-To: <1301934004-6204-3-git-send-email-berrange@redhat.com>
References: <1301934004-6204-1-git-send-email-berrange@redhat.com>
<1301934004-6204-3-git-send-email-berrange@redhat.com>
Message-ID: <4D9A2BEC.1080809@redhat.com>
On 04/04/2011 10:20 AM, Daniel P. Berrange wrote:
> Split the bit acinclude.m4 file into smaller pieces named
> as m4/virt-XXXXX.m4
>
> * .gitignore: Ignore gettext related files
> * acinclude.m4: Delete
> * m4/virt-compile-warnings.m4: Checks for GCC compiler flags
> * m4/virt-pkgconfig-back-compat.m4: Backcompat check for
> pkgconfig program
> ---
> .gitignore | 36 +++++++++-
> acinclude.m4 | 137 --------------------------------------
> m4/virt-compile-warnings.m4 | 112 +++++++++++++++++++++++++++++++
> m4/virt-pkgconfig-back-compat.m4 | 23 ++++++
> 4 files changed, 169 insertions(+), 139 deletions(-)
> delete mode 100644 acinclude.m4
> create mode 100644 m4/virt-compile-warnings.m4
> create mode 100644 m4/virt-pkgconfig-back-compat.m4
>
> diff --git a/.gitignore b/.gitignore
> index ba4d351..278bc4f 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -1,4 +1,3 @@
> -!/m4/compiler-flags.m4
> !/po/*.po
> !/po/POTFILES.in
> !/po/libvirt.pot
> @@ -46,7 +45,6 @@
> /libvirt.spec
Yuck - gnulib's bootstrap script sorts .gitignore, but this is broken
(lines starting with ! should come last, not first, according to 'man
gitignore'; it's a shame I'm just noticing it now, since it's been
broken since November 2010).
> @@ -67,3 +65,37 @@ results.log
> stamp-h
> stamp-h.in
> stamp-h1
> +m4/codeset.m4
> +m4/gettext.m4
Rerunning bootstrap will re-sort this list, leading to spurious diffs
unless we get it sorted first. But why should we blacklist all of the
m4 files individually, when it is much easier to whitelist just the
files we want?
/m4/
!/m4/virt-*.m4
I've posted an upstream bug to gnulib about bootstrap botching sort
order; let's get that fixed first and then respin this patch on top of
that one.
However, even though it's not ready for prime-time yet, I'm pleased with
the concept of splitting things into easier-to-find per-file macros.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From eblake at redhat.com Mon Apr 4 20:40:28 2011
From: eblake at redhat.com (Eric Blake)
Date: Mon, 04 Apr 2011 14:40:28 -0600
Subject: [libvirt] [PATCH 3/6] Enable -Wmissing-format-attribute warning
In-Reply-To: <1301934004-6204-4-git-send-email-berrange@redhat.com>
References: <1301934004-6204-1-git-send-email-berrange@redhat.com>
<1301934004-6204-4-git-send-email-berrange@redhat.com>
Message-ID: <4D9A2CBC.8060401@redhat.com>
On 04/04/2011 10:20 AM, Daniel P. Berrange wrote:
> Add a couple of missing ATTRIBUTE_FMT_PRINTF annotations
>
> * tools/virsh.c, tests/testutils.c: Add printf format attribute
> * m4/virt-compile-warnings.m4: Enable -Wmissing-format-attribute
>
> -
> +ATTRIBUTE_FMT_PRINTF(3,4)
> void virtTestResult(const char *name, int ret, const char *msg, ...)
gcc attribute syntax is screwy.
I'm somewhat used to:
void ATTRIBUTE_FMT_PRINTF(3,4)
virtTestResult(...)
but if doing the attribute before the return type works, great.
> {
> va_list vargs;
> diff --git a/tools/virsh.c b/tools/virsh.c
> index 19e3449..4765f5c 100644
> --- a/tools/virsh.c
> +++ b/tools/virsh.c
> @@ -243,7 +243,8 @@ static int vshInit(vshControl *ctl);
> static int vshDeinit(vshControl *ctl);
> static void vshUsage(void);
> static void vshOpenLogFile(vshControl *ctl);
> -static void vshOutputLogFile(vshControl *ctl, int log_level, const char *format, va_list ap);
> +static void vshOutputLogFile(vshControl *ctl, int log_level, const char *format, va_list ap)
> + ATTRIBUTE_FMT_PRINTF(3, 0);
> static void vshCloseLogFile(vshControl *ctl);
ACK (although rebasing this to apply before we fix patch 2/6 vs. gnulib
bootstrap may not be worth your time).
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From eblake at redhat.com Mon Apr 4 20:42:18 2011
From: eblake at redhat.com (Eric Blake)
Date: Mon, 04 Apr 2011 14:42:18 -0600
Subject: [libvirt] [PATCH 4/6] Enable use of -Wmissing-noreturn
In-Reply-To: <1301934004-6204-5-git-send-email-berrange@redhat.com>
References: <1301934004-6204-1-git-send-email-berrange@redhat.com>
<1301934004-6204-5-git-send-email-berrange@redhat.com>
Message-ID: <4D9A2D2A.3060108@redhat.com>
On 04/04/2011 10:20 AM, Daniel P. Berrange wrote:
> * src/internal.h: Define a ATTRIBUTE_NO_RETURN annotation
> * src/lxc/lxc_container.c: Annotate lxcContainerDummyChild
> with ATTRIBUTE_NO_RETURN
> * tests/eventtest.c: Mark async thread as ATTRIBUTE_NO_RETURN
> * m4/virt-compile-warnings.m4: Enable -Wmissing-noreturn
> ---
> m4/virt-compile-warnings.m4 | 1 -
> src/internal.h | 9 +++++++++
> src/lxc/lxc_container.c | 3 ++-
> tests/eventtest.c | 3 +--
> 4 files changed, 12 insertions(+), 4 deletions(-)
>
> +++ b/src/internal.h
> @@ -117,6 +117,15 @@
> # endif
>
> /**
> + * ATTRIBUTE_NORETURN:
> + *
> + * Macro to indicate that a function won't return to the caller
> + */
> +# ifndef ATTRIBUTE_NORETURN
> +# define ATTRIBUTE_NORETURN __attribute__((__noreturn__))
> +# endif
Do we need a minimum gcc version detection, so this cause grief on older
setups?
At any rate, ACK.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From eblake at redhat.com Mon Apr 4 20:44:21 2011
From: eblake at redhat.com (Eric Blake)
Date: Mon, 04 Apr 2011 14:44:21 -0600
Subject: [libvirt] [PATCH 5/6] Enable use of -Wold-style-definition
compiler flag
In-Reply-To: <1301934004-6204-6-git-send-email-berrange@redhat.com>
References: <1301934004-6204-1-git-send-email-berrange@redhat.com>
<1301934004-6204-6-git-send-email-berrange@redhat.com>
Message-ID: <4D9A2DA5.8040900@redhat.com>
On 04/04/2011 10:20 AM, Daniel P. Berrange wrote:
> A couple of functions were declared using the old style foo()
> for no-parameters, instead of foo(void)
>
> * src/xen/xen_hypervisor.c, tests/testutils.c: Replace () with (void)
> in some function declarations
> * m4/virt-compile-warnings.m4: Enable -Wold-style-definition
> ---
> m4/virt-compile-warnings.m4 | 1 -
> src/xen/xen_hypervisor.c | 2 +-
> tests/testutils.c | 4 ++--
> 3 files changed, 3 insertions(+), 4 deletions(-)
ACK.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From eblake at redhat.com Mon Apr 4 20:54:28 2011
From: eblake at redhat.com (Eric Blake)
Date: Mon, 04 Apr 2011 14:54:28 -0600
Subject: [libvirt] [PATCH 6/6] Remove unused macros and
enable -Wunused-macros
In-Reply-To: <1301934004-6204-7-git-send-email-berrange@redhat.com>
References: <1301934004-6204-1-git-send-email-berrange@redhat.com>
<1301934004-6204-7-git-send-email-berrange@redhat.com>
Message-ID: <4D9A3004.50305@redhat.com>
On 04/04/2011 10:20 AM, Daniel P. Berrange wrote:
> * m4/virt-compile-warnings.m4: Enable -Wunused-macros
> * daemon/libvirtd.c: Remove MAX_LISTEN
> * daemon/remote.c: Remote VIR_FROM_THIS
s/Remote/Remove/
> 33 files changed, 38 insertions(+), 108 deletions(-)
Nice ratio!
> +++ b/src/esx/esx_vi_methods.c
> @@ -1,4 +1,3 @@
> -
> /*
> * esx_vi_methods.c: client for the VMware VI API 2.5 to manage ESX hosts
> *
> @@ -52,8 +51,10 @@
>
>
>
> +#if 0
> #define ESX_VI__METHOD__CHECK_OUTPUT__RequiredList \
Won't this cause 'make syntax-check' grief during cppi checks? (Multiple
instances)
> +++ b/tools/virsh.c
> @@ -409,15 +409,6 @@ _vshStrdup(vshControl *ctl, const char *s, const char *filename, int line)
> exit(EXIT_FAILURE);
> }
>
> -/* Poison the raw allocating identifiers in favor of our vsh variants. */
> -#undef malloc
> -#undef calloc
> -#undef realloc
> -#undef strdup
> -#define malloc use_vshMalloc_instead_of_malloc
> -#define calloc use_vshCalloc_instead_of_calloc
> -#define realloc use_vshRealloc_instead_of_realloc
> -#define strdup use_vshStrdup_instead_of_strdup
Hmm, I don't want to completely lose this. Can we instead include
"warn-on-use.h" (already provided by gnulib) and do:
_GL_WARN_ON_USE(malloc, "use vshMalloc instead of malloc");
to get the same poisoning effects but via magic attributes rather than
unused macros?
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From jdenemar at redhat.com Mon Apr 4 22:08:17 2011
From: jdenemar at redhat.com (Jiri Denemark)
Date: Tue, 5 Apr 2011 00:08:17 +0200
Subject: [libvirt] [PATCH] qemu: Ignore unusable binaries
Message-ID:
When initializing qemu guest capabilities, we should ignore qemu
binaries that we are not able to extract version/help info from since
they will be unusable for creating domains anyway. Ignoring them is also
much better than letting initialization of qemu driver fail.
---
src/qemu/qemu_capabilities.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index f86e7f5..63486cc 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -490,6 +490,12 @@ qemuCapsInitGuest(virCapsPtr caps,
if (!binary)
return 0;
+ /* Ignore binary if extracting version info fails */
+ if (qemuCapsExtractVersionInfo(binary, info->arch, NULL, &qemuCaps) < 0) {
+ ret = 0;
+ goto cleanup;
+ }
+
if (stat(binary, &st) == 0) {
binary_mtime = st.st_mtime;
} else {
@@ -554,9 +560,8 @@ qemuCapsInitGuest(virCapsPtr caps,
!virCapabilitiesAddGuestFeature(guest, "cpuselection", 1, 0))
goto error;
- if (qemuCapsExtractVersionInfo(binary, info->arch, NULL, &qemuCaps) < 0 ||
- (qemuCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX) &&
- !virCapabilitiesAddGuestFeature(guest, "deviceboot", 1, 0)))
+ if (qemuCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX) &&
+ !virCapabilitiesAddGuestFeature(guest, "deviceboot", 1, 0))
goto error;
if (hvm) {
--
1.7.4.1
From eblake at redhat.com Mon Apr 4 22:09:12 2011
From: eblake at redhat.com (Eric Blake)
Date: Mon, 04 Apr 2011 16:09:12 -0600
Subject: [libvirt] [PATCH 07/12] Introduce generic RPC server objects
In-Reply-To: <1300474467-23485-8-git-send-email-berrange@redhat.com>
References: <1300474467-23485-1-git-send-email-berrange@redhat.com>
<1300474467-23485-8-git-send-email-berrange@redhat.com>
Message-ID: <4D9A4188.2050301@redhat.com>
On 03/18/2011 12:54 PM, Daniel P. Berrange wrote:
> To facilitate creation of new daemons providing XDR RPC services,
> pull alot of the libvirtd daemon code into a set of reusable
> objects.
Part 3. Hopefully I finish before sending this time.
> +int virNetServerAddService(virNetServerPtr srv,
> + virNetServerServicePtr svc)
> +
> +int virNetServerSetTLSContext(virNetServerPtr srv,
> + virNetTLSContextPtr tls)
> +{
> + srv->tls = tls;
> + virNetTLSContextRef(tls);
> + return 0;
No virNetServerLock(srv)?
> +static void virNetServerAutoShutdownTimer(int timerid ATTRIBUTE_UNUSED,
> + void *opaque) {
> + virNetServerPtr srv = opaque;
> +
> + virNetServerLock(srv);
> +
> + if (srv->autoShutdownFunc(srv, srv->autoShutdownOpaque)) {
> + VIR_DEBUG0("Automatic shutdown triggered");
> + srv->quit = 1;
Should srv->quit be bool instead of int?
> +void virNetServerRun(virNetServerPtr srv)
> +{
> + int timerid = -1;
> + int timerActive = 0;
> + int i;
> +
> + virNetServerLock(srv);
> +
> + if (srv->autoShutdownTimeout &&
> + (timerid = virEventAddTimeout(-1,
> + virNetServerAutoShutdownTimer,
> + srv, NULL)) < 0) {
> + virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
> + _("Failed to register shutdown timeout"));
> + goto cleanup;
> + }
> +
> + while (!srv->quit) {
> + /* A shutdown timeout is specified, so check
> + * if any drivers have active state, if not
> + * shutdown after timeout seconds
> + */
> + if (srv->autoShutdownTimeout) {
> + if (timerActive) {
> + if (srv->clients) {
> + VIR_DEBUG("Deactivating shutdown timer %d", timerid);
> + virEventUpdateTimeout(timerid, -1);
> + timerActive = 0;
> + }
> + } else {
> + if (!srv->clients) {
> + VIR_DEBUG("Activating shutdown timer %d", timerid);
> + virEventUpdateTimeout(timerid,
> + srv->autoShutdownTimeout * 1000);
Do we need to worry about overflow here (that is, should
srv->autoShutdownTimeout be validated to be less than INT_MAX/1000
earlier on)?
> + timerActive = 1;
> + }
> + }
> + }
> +
> + virNetServerUnlock(srv);
> + if (virEventRunDefaultImpl() < 0) {
> + virNetServerLock(srv);
> + VIR_DEBUG0("Loop iteration error, exiting");
> + break;
> + }
> + virNetServerLock(srv);
> +
> + reprocess:
> + for (i = 0 ; i < srv->nclients ; i++) {
> + if (virNetServerClientWantClose(srv->clients[i]))
> + virNetServerClientClose(srv->clients[i]);
> + if (virNetServerClientIsClosed(srv->clients[i])) {
> + virNetServerClientFree(srv->clients[i]);
Do we really want to hold the server lock while calling these two
client-related functions? Or is this a recipe for deadlock?
> +++ b/src/rpc/virnetserver.h
> @@ -0,0 +1,80 @@
> +
> +# include
"internal.h" should guarantee this
> +
> +void virNetServerRef(virNetServerPtr srv);
ATTRIBUTE_NONNULL(1)
> +
> +bool virNetServerIsPrivileged(virNetServerPtr srv);
ATTRIBUTE_NONNULL(1)
> +
> +void virNetServerAutoShutdown(virNetServerPtr srv,
> + unsigned int timeout,
> + virNetServerAutoShutdownFunc func,
> + void *opaque);
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3)
> +
> +typedef void (*virNetServerSignalFunc)(virNetServerPtr srv, siginfo_t *info, void *opaque);
> +
> +int virNetServerAddSignalHandler(virNetServerPtr srv,
> + int signum,
> + virNetServerSignalFunc func,
> + void *opaque);
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3)
> +
> +int virNetServerAddService(virNetServerPtr srv,
> + virNetServerServicePtr svc);
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
> +
> +int virNetServerAddProgram(virNetServerPtr srv,
> + virNetServerProgramPtr prog);
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
> +
> +int virNetServerSetTLSContext(virNetServerPtr srv,
> + virNetTLSContextPtr tls);
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
> +
> +void virNetServerUpdateServices(virNetServerPtr srv,
> + bool enabled);
ATTRIBUTE_NONNULL(1)
> +
> +void virNetServerRun(virNetServerPtr srv);
ATTRIBUTE_NONNULL(1)
> +
> +void virNetServerQuit(virNetServerPtr srv);
ATTRIBUTE_NONNULL(1)
> +++ b/src/rpc/virnetserverclient.c
> @@ -0,0 +1,938 @@
> +
> +#include
> +
> +#if HAVE_SASL
> +# include
> +#endif
Do we really need this, or did it get taken care of by hiding all SASL
details behind virNetSASL*
> +struct _virNetServerClient
> +{
> + int refs;
> + bool wantClose;
> + virMutex lock;
> + virNetSocketPtr sock;
> + int auth;
> + bool readonly;
> + char *identity;
> + virNetTLSContextPtr tlsCtxt;
> + virNetTLSSessionPtr tls;
> +#if HAVE_SASL
> + virNetSASLSessionPtr sasl;
> +#endif
> +
> + /* Count of messages in the 'tx' queue,
> + * and the server worker pool queue
> + * ie RPC calls in progress. Does not count
s/ie/i.e./
> + * async events which are not used for
> + * throttling calculations */
> + size_t nrequests;
> + size_t nrequests_max;
> + /* Zero or one messages being received. Zero if
> + * nrequests >= max_clients and throttling */
> + virNetMessagePtr rx;
> + /* Zero or many messages waiting for transmit
> + * back to client, including async events */
> + virNetMessagePtr tx;
> +
> + /* Filters to capture messages that would otherwise
> + * end up on the 'dx' queue */
dx? Did you mean tx?
> +
> +/*
> + * @server: a locked or unlocked server object
> + * @client: a locked client object
> + */
> +static int virNetServerClientRegisterEvent(virNetServerClientPtr client)
No @server argument; too much copy-n-paste?
> +
> +int virNetServerClientAddFilter(virNetServerClientPtr client,
> + virNetServerClientFilterFunc func,
> + void *opaque)
No docs?
> +
> +
> +void virNetServerClientRemoveFilter(virNetServerClientPtr client,
> + int filterID)
> +{
> + virNetServerClientFilterPtr tmp, prev;
> + virNetServerClientLock(client);
> +
> + prev = NULL;
> + tmp = client->filters;
> + while (tmp) {
> + if (tmp->id == filterID) {
> + if (prev)
> + prev->next = tmp->next;
> + else
> + client->filters = tmp->next;
> +
> + VIR_FREE(tmp);
> + break;
> + }
> + tmp = tmp->next;
> + }
Where does prev get set in that loop?
> +
> +
> +virNetServerClientPtr virNetServerClientNew(virNetSocketPtr sock,
> + int auth,
> + bool readonly,
> + virNetTLSContextPtr tls)
> +{
> + virNetServerClientPtr client;
> +
> + VIR_DEBUG("sock=%p auth=%d tls=%p", sock, auth, tls);
> +
> + if (VIR_ALLOC(client) < 0) {
> + virReportOOMError();
> + return NULL;
> + }
> +
> + if (virMutexInit(&client->lock) < 0)
> + goto error;
> +
> + client->refs = 1;
> + client->sock = sock;
> + client->auth = auth;
> + client->readonly = readonly;
> + client->tlsCtxt = tls;
> + client->nrequests_max = 10; /* XXX */
Any plans to change this, such as making it a caller-settable parameter
(which the caller can then load from a conf file)? Does it really matter?
> +
> + if (tls)
> + virNetTLSContextRef(tls);
> +
> + /* Prepare one for packet receive */
> + if (!(client->rx = virNetMessageNew()))
> + goto error;
> + client->rx->bufferLength = VIR_NET_MESSAGE_LEN_MAX;
> + client->nrequests = 1;
> +
> + VIR_DEBUG("client=%p refs=%d", client, client->refs);
> +
> + return client;
> +
> +error:
> + /* XXX ref counting is better than this */
> + client->sock = NULL; /* Caller owns 'sock' upon failure */
> + virNetServerClientFree(client);
Should we clean this up first?
> +
> +void virNetServerClientRef(virNetServerClientPtr client)
> +{
> + virNetServerClientLock(client);
> + client->refs++;
> + VIR_DEBUG("client=%p refs=%d", client, client->refs);
> + virNetServerClientUnlock(client);
virObject and atomic ref-counting seems like it might be nice to get in
first.
> +bool virNetServerClientGetReadonly(virNetServerClientPtr client)
> +{
> + bool readonly;
> + virNetServerClientLock(client);
> + readonly = client->readonly;
> + virNetServerClientUnlock(client);
> + return readonly;
Do we need to lock in order to read data that should never be changed
after the client is first created?
> +int virNetServerClientGetFD(virNetServerClientPtr client)
> +{
> + int fd = 0;
Why do you init this to 0,
> + virNetServerClientLock(client);
> + fd = virNetSocketGetFD(client->sock);
> + virNetServerClientUnlock(client);
> + return fd;
if it will always get overwritten, and since -1 is a safer init value
for an fd?
> +bool virNetServerClientIsSecure(virNetServerClientPtr client)
> +{
> + bool secure = false;
> + virNetServerClientLock(client);
> + if (client->tls)
> + secure = true;
> +#if HAVE_SASL
> + if (client->sasl)
else if
> + secure = true;
> +#endif
> + if (virNetSocketIsLocal(client->sock))
else if (no need to spend time on calling virNetSocketIsLocal if we
already had our answer from client->tls or client->sasl)
> +void virNetServerClientSetPrivateData(virNetServerClientPtr client,
> + void *opaque,
> + virNetServerClientFreeFunc ff)
> +{
> + virNetServerClientLock(client);
> +
> + if (client->privateData &&
> + client->privateDataFreeFunc)
> + client->privateDataFreeFunc(client->privateData);
Should this be deferred, and the old function and data cached for
calling after locks are dropped, so that the callback can't deadlock
with other client-locked functions?
> +void virNetServerClientFree(virNetServerClientPtr client)
> +{
> + if (!client)
> + return;
> +
> + virNetServerClientLock(client);
> + VIR_DEBUG("client=%p refs=%d", client, client->refs);
> +
> + client->refs--;
> + if (client->refs > 0) {
> + virNetServerClientUnlock(client);
> + return;
> + }
> +
> + if (client->privateData &&
> + client->privateDataFreeFunc)
> + client->privateDataFreeFunc(client->privateData);
Likewise to calling this outside lock?
> +/*
> + *
> + * We don't free stuff here, merely disconnect the client's
> + * network socket & resources.
> + *
> + * Full free of the client is done later in a safe point
> + * where it can be guaranteed it is no longer in use
> + */
> +void virNetServerClientClose(virNetServerClientPtr client)
> +{
> + virNetServerClientLock(client);
> + VIR_DEBUG("client=%p refs=%d", client, client->refs);
> + if (!client->sock) {
> + virNetServerClientUnlock(client);
> + return;
> + }
> +
> + /* Do now, even though we don't close the socket
> + * until end, to ensure we don't get invoked
> + * again due to tls shutdown */
> + if (client->sock)
> + virNetSocketRemoveIOCallback(client->sock);
> +
> + if (client->tls) {
> + virNetTLSSessionFree(client->tls);
> + client->tls = NULL;
> + }
> + if (client->sock) {
> + virNetSocketFree(client->sock);
> + client->sock = NULL;
> + }
> +
> + while (client->rx) {
> + virNetMessagePtr msg
> + = virNetMessageQueueServe(&client->rx);
> + virNetMessageFree(msg);
> + }
> + while (client->tx) {
> + virNetMessagePtr msg
> + = virNetMessageQueueServe(&client->tx);
> + virNetMessageFree(msg);
> + }
Should we flush tx before rx, in case the act of flushing tx results in
a couple more responses received?
> +bool virNetServerClientIsClosed(virNetServerClientPtr client)
> +{
> + bool closed;
> + virNetServerClientLock(client);
> + closed = client->sock == NULL ? true : false;
I would have written closed = (client->sock == NULL) or even closed =
!!client->sock
> +
> +/*
> + * Read data until we get a complete message to process
> + */
> +static void virNetServerClientDispatchRead(virNetServerClientPtr client)
> +{
> +readmore:
> + if (virNetServerClientRead(client) < 0) {
> + client->wantClose = true;
> + return; /* Error */
> + }
> +
> + if (client->rx->bufferOffset < client->rx->bufferLength)
> + return; /* Still not read enough */
> +
> + /* Either done with length word header */
> + if (client->rx->bufferLength == VIR_NET_MESSAGE_LEN_MAX) {
> + if (virNetMessageDecodeLength(client->rx) < 0)
> + return;
> +
> + virNetServerClientUpdateEvent(client);
> +
> + /* Try and read payload immediately instead of going back
> + into poll() because chances are the data is already
> + waiting for us */
> + goto readmore;
> + } else {
> + /* Grab the completed message */
> + virNetMessagePtr msg = virNetMessageQueueServe(&client->rx);
> + virNetServerClientFilterPtr filter;
> +
> + /* Decode the header so we can use it for routing decisions */
> + if (virNetMessageDecodeHeader(msg) < 0) {
> + virNetMessageFree(msg);
> + client->wantClose = true;
> + return;
> + }
> +
> + /* Maybe send off for queue against a filter */
> + filter = client->filters;
> + while (filter) {
> + int ret = filter->func(client, msg, filter->opaque);
> + if (ret < 0 || ret > 0) {
ret != 0
When do the filters return > 0?
> + virNetMessageFree(msg);
> + msg = NULL;
> + if (ret < 0)
> + client->wantClose = true;
> + break;
> + }
> +
> + filter = filter->next;
> + }
> +
> + /* Send off to for normal dispatch to workers */
> + if (msg) {
> + if (!client->dispatchFunc ||
> + client->dispatchFunc(client, msg, client->dispatchOpaque) < 0) {
Should we log the case of client->dispatchFunc being NULL?
> +
> +static void
> +virNetServerClientDispatchHandshake(virNetServerClientPtr client)
> +{
> + int ret;
> + /* Continue the handshake. */
> + ret = virNetTLSSessionHandshake(client->tls);
> + if (ret == 0) {
> + /* Finished. Next step is to check the certificate. */
> + if (virNetServerClientCheckAccess(client) < 0)
> + client->wantClose = true;
> + else
> + virNetServerClientUpdateEvent(client);
> + } else if (ret > 0) {
> + /* Carry on waiting for more handshake. Update
> + the events just in case handshake data flow
> + direction has changed */
> + virNetServerClientUpdateEvent (client);
s/ (/(/
> +++ b/src/rpc/virnetserverclient.h
> @@ -0,0 +1,106 @@
> +
> +virNetServerClientPtr virNetServerClientNew(virNetSocketPtr sock,
> + int auth,
> + bool readonly,
> + virNetTLSContextPtr tls);
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4)
> +
> +int virNetServerClientAddFilter(virNetServerClientPtr client,
> + virNetServerClientFilterFunc func,
> + void *opaque);
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK
> +
> +void virNetServerClientRemoveFilter(virNetServerClientPtr client,
> + int filterID);
ATTRIBUTE_NONNULL(1)
> +
> +int virNetServerClientGetAuth(virNetServerClientPtr client);
ATTRIBUTE_NONNULL(1)
> +bool virNetServerClientGetReadonly(virNetServerClientPtr client);
ATTRIBUTE_NONNULL(1)
> +
> +bool virNetServerClientHasTLSSession(virNetServerClientPtr client);
ATTRIBUTE_NONNULL(1)
> +int virNetServerClientGetTLSKeySize(virNetServerClientPtr client);
ATTRIBUTE_NONNULL(1)
> +
> +#ifdef HAVE_SASL
> +void virNetServerClientSetSASLSession(virNetServerClientPtr client,
> + virNetSASLSessionPtr sasl);
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
> +#endif
> +
> +int virNetServerClientGetFD(virNetServerClientPtr client);
ATTRIBUTE_NONNULL(1)
> +
> +bool virNetServerClientIsSecure(virNetServerClientPtr client);
ATTRIBUTE_NONNULL(1)
> +
> +int virNetServerClientSetIdentity(virNetServerClientPtr client,
> + const char *identity);
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
> +const char *virNetServerClientGetIdentity(virNetServerClientPtr client);
ATTRIBUTE_NONNULL(1)
> +
> +int virNetServerClientGetLocalIdentity(virNetServerClientPtr client,
> + uid_t *uid, pid_t *pid);
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
> +
> +void virNetServerClientRef(virNetServerClientPtr client);
ATTRIBUTE_NONNULL(1)
> +
> +typedef void (*virNetServerClientFreeFunc)(void *data);
> +
> +void virNetServerClientSetPrivateData(virNetServerClientPtr client,
> + void *opaque,
> + virNetServerClientFreeFunc ff);
ATTRIBUTE_NONNULL(1)
> +void *virNetServerClientGetPrivateData(virNetServerClientPtr client);
ATTRIBUTE_NONNULL(1)
> +
> +void virNetServerClientSetDispatcher(virNetServerClientPtr client,
> + virNetServerClientDispatchFunc func,
> + void *opaque);
ATTRIBUTE_NONNULL(1)
> +void virNetServerClientClose(virNetServerClientPtr client);
ATTRIBUTE_NONNULL(1)
> +
> +bool virNetServerClientIsClosed(virNetServerClientPtr client);
ATTRIBUTE_NONNULL(1)
> +void virNetServerClientMarkClose(virNetServerClientPtr client);
ATTRIBUTE_NONNULL(1)
> +bool virNetServerClientWantClose(virNetServerClientPtr client);
ATTRIBUTE_NONNULL(1)
> +
> +int virNetServerClientInit(virNetServerClientPtr client);
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK
> +
> +const char *virNetServerClientLocalAddrString(virNetServerClientPtr client);
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK
> +const char *virNetServerClientRemoteAddrString(virNetServerClientPtr client);
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK
> +
> +int virNetServerClientSendMessage(virNetServerClientPtr client,
> + virNetMessagePtr msg);
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
> +
> +bool virNetServerClientNeedAuth(virNetServerClientPtr client);
ATTRIBUTE_NONNULL(1)
> +++ b/src/rpc/virnetserverprogram.c
> +static int
> +virNetServerProgramDispatchCall(virNetServerProgramPtr prog,
> + virNetServerPtr server,
> + virNetServerClientPtr client,
> + virNetMessagePtr msg)
> +{
> + /*
> + * When the RPC handler is called:
> + *
> + * - Server object is unlocked
> + * - Client object is unlocked
> + *
> + * Without locking, it is safe to use:
> + *
> + * 'args and 'ret'
s/'args/'args'/
> +++ b/src/rpc/virnetserverprogram.h
> @@ -0,0 +1,107 @@
> +# define __VIR_NET_PROGRAM_H__
> +
> +# include
Provided by "internal.h"
> +
> +struct _virNetServerProgramProc {
> + virNetServerProgramDispatchFunc func;
> + size_t arg_len;
> + xdrproc_t arg_filter;
> + size_t ret_len;
> + xdrproc_t ret_filter;
> + bool needAuth;
> +};
> +
> +virNetServerProgramPtr virNetServerProgramNew(unsigned program,
> + unsigned version,
> + virNetServerProgramProcPtr procs,
> + size_t nprocs);
ATTRIBUTE_NONNULL(3)
> +
> +int virNetServerProgramGetID(virNetServerProgramPtr prog);
ATTRIBUTE_NONNULL(1)
> +int virNetServerProgramGetVersion(virNetServerProgramPtr prog);
ATTRIBUTE_NONNULL(1)
> +
> +void virNetServerProgramRef(virNetServerProgramPtr prog);
ATTRIBUTE_NONNULL(1)
> +
> +int virNetServerProgramMatches(virNetServerProgramPtr prog,
> + virNetMessagePtr msg);
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
> +
> +int virNetServerProgramDispatch(virNetServerProgramPtr prog,
> + virNetServerPtr server,
> + virNetServerClientPtr client,
> + virNetMessagePtr msg);
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
ATTRIBUTE_NONNULL(4)
> +
> +int virNetServerProgramSendReplyError(virNetServerProgramPtr prog,
> + virNetServerClientPtr client,
> + virNetMessagePtr msg,
> + virNetMessageErrorPtr rerr,
> + virNetMessageHeaderPtr req);
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5)
> +
> +int virNetServerProgramSendStreamError(virNetServerProgramPtr prog,
> + virNetServerClientPtr client,
> + virNetMessagePtr msg,
> + virNetMessageErrorPtr rerr,
> + int procedure,
> + int serial);
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
ATTRIBUTE_NONNULL(4)
> +
> +int virNetServerProgramSendStreamData(virNetServerProgramPtr prog,
> + virNetServerClientPtr client,
> + virNetMessagePtr msg,
> + int procedure,
> + int serial,
> + const char *data,
> + size_t len);
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
ATTRIBUTE_NONNULL(6)
> +
> +++ b/src/rpc/virnetserverservice.c
> +
> +static void virNetServerServiceAccept(virNetSocketPtr sock,
> + int events ATTRIBUTE_UNUSED,
> + void *opaque)
> +{
> + virNetServerServicePtr svc = opaque;
> + virNetServerClientPtr client = NULL;
> + virNetSocketPtr clientsock = NULL;
> +
> + if (virNetSocketAccept(sock, &clientsock) < 0)
> + goto error;
> +
> + if (!clientsock) /* Connection already went away */
> + goto cleanup;
Why not just return;?
> +
> + if (!(client = virNetServerClientNew(clientsock,
> + svc->auth,
> + svc->readonly,
> + svc->tls)))
> + goto error;
> +
> + if (!svc->dispatchFunc)
> + goto error;
> +
> + if (svc->dispatchFunc(svc, client, svc->dispatchOpaque) < 0)
> + virNetServerClientClose(client);
> +
> + virNetServerClientFree(client);
> +
> +cleanup:
> + return;
and avoid an extra label?
> +++ b/src/rpc/virnetserverservice.h
> @@ -0,0 +1,65 @@
> +
> +virNetServerServicePtr virNetServerServiceNewTCP(const char *nodename,
> + const char *service,
> + int auth,
> + bool readonly,
> + virNetTLSContextPtr tls);
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(5)
> +virNetServerServicePtr virNetServerServiceNewUNIX(const char *path,
> + mode_t mask,
> + gid_t grp,
> + int auth,
> + bool readonly,
> + virNetTLSContextPtr tls);
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(6)
> +
> +int virNetServerServiceGetAuth(virNetServerServicePtr svc);
ATTRIBUTE_NONNULL(1)
> +bool virNetServerServiceIsReadonly(virNetServerServicePtr svc);
ATTRIBUTE_NONNULL(1)
> +
> +void virNetServerServiceRef(virNetServerServicePtr svc);
ATTRIBUTE_NONNULL(1)
> +
> +void virNetServerServiceSetDispatcher(virNetServerServicePtr svc,
> + virNetServerServiceDispatchFunc func,
> + void *opaque);
ATTRIBUTE_NONNULL(1)
> +
> +void virNetServerServiceFree(virNetServerServicePtr svc);
> +
> +void virNetServerServiceToggle(virNetServerServicePtr svc,
> + bool enabled);
ATTRIBUTE_NONNULL(1)
Phew. I finished reviewing this. I think I found several points worth
fixing (both here and in the first two messages reviewing the same
mail), and you'll probably have other changes when rebasing to latest.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From eblake at redhat.com Mon Apr 4 22:14:00 2011
From: eblake at redhat.com (Eric Blake)
Date: Mon, 04 Apr 2011 16:14:00 -0600
Subject: [libvirt] [PATCH] virsh: Increase device-detach intelligence
In-Reply-To: <1301065746-12468-1-git-send-email-mprivozn@redhat.com>
References: <1301065746-12468-1-git-send-email-mprivozn@redhat.com>
Message-ID: <4D9A42A8.1040206@redhat.com>
On 03/25/2011 09:09 AM, Michal Privoznik wrote:
> Up to now users have to give a full XML description on input when
> device-detaching. If they omited something it lead to unclear
> error messages (like generated MAC wasn't found, etc.).
> With this patch users can specify only those information which
> specify one device sufficiently precise. Remaining information is
> completed from domain.
> ---
> tools/virsh.c | 260 +++++++++++++++++++++++++++++++++++++++++++++++++++++----
> 1 files changed, 245 insertions(+), 15 deletions(-)
Not forgotten, but not quite yet to the top of my queue, either :( I
guess having too many patches to review is a good sign that there is a
lot of contribution going on.
>
> diff --git a/tools/virsh.c b/tools/virsh.c
> index 50ca50f..95d27f7 100644
> --- a/tools/virsh.c
> +++ b/tools/virsh.c
> @@ -8702,6 +8702,224 @@ cmdAttachDevice(vshControl *ctl, const vshCmd *cmd)
> return TRUE;
> }
>
> +/**
> + * Check if n1 is superset of n2, meaning n1 contains all elements and
> + * attributes as n2 at lest. Including children.
> + * @n1 first node
> + * @n2 second node
> + * return 1 in case n1 covers n2, 0 otherwise.
> + */
> +static int
> +vshNodeIsSuperset(xmlNodePtr n1, xmlNodePtr n2) {
Are there any xml library functions that can already do this without you
rewriting it from scratch?
> +/**
> + * To given domain and (probably incomplete) device XML specification try to
> + * find such device in domain and complete missing parts. This is however
> + * possible when given device XML is sufficiently precise so it addresses only
> + * one device.
> + * @ctl vshControl for error messages printing
> + * @dom domain
> + * @oldXML device XML before
> + * @newXML and after completion
> + * Returns -2 when no such device exists in domain, -3 when given XML selects many
> + * (is too ambiguous), 0 in case of success. Otherwise returns -1. @newXML
> + * is touched only in case of success.
> + */
> +static int
> +vshCompleteXMLFromDomain(vshControl *ctl, virDomainPtr dom, char *oldXML,
> + char **newXML) {
My quick glance of just the documentation says that this looks like a
nice helper, but I haven't reviewed it in depth.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From jdenemar at redhat.com Mon Apr 4 22:16:10 2011
From: jdenemar at redhat.com (Jiri Denemark)
Date: Tue, 5 Apr 2011 00:16:10 +0200
Subject: [libvirt] [PATCH] qemu: Don't fail driver startup with ancient
qemu
In-Reply-To: <20110404182437.GD4156@redhat.com>
References: <2e1f2e4705bb467bcf237647706555bf4e97ec1e.1301923139.git.jdenemar@redhat.com>
<20110404132359.GC13616@redhat.com>
<20110404133732.GH389283@orkuz.home>
<20110404182437.GD4156@redhat.com>
Message-ID: <20110404221610.GI389283@orkuz.home>
On Mon, Apr 04, 2011 at 14:24:37 -0400, Dave Allan wrote:
> On Mon, Apr 04, 2011 at 03:37:32PM +0200, Jiri Denemark wrote:
> > On Mon, Apr 04, 2011 at 14:23:59 +0100, Daniel P. Berrange wrote:
> > > On Mon, Apr 04, 2011 at 03:18:59PM +0200, Jiri Denemark wrote:
> > > > Failure to extract version info (e.g., because qemu binary is so ancient
> > > > that it doesn't even support -help) shouldn't be considered fatal since
> > > > we only need it to detect whether qemu supports bootindex option.
> > > > ---
> > > > src/qemu/qemu_capabilities.c | 7 ++++---
> > > > 1 files changed, 4 insertions(+), 3 deletions(-)
> > >
> > > What version QEMU doesn't support -help ?
> > >
> > > We only aim to work with QEMU >= 0.9.0 and I'm fairly sure
> > > that has -help support.
> >
> > An ancient one, 0.6.0. But that was just an example. Extracting version info
> > may fail for a bunch of reasons. The main thing is that it shouldn't fail qemu
> > driver startup since that results in libvirtd startup failure.
>
> Why does driver startup failure result in libvirtd startup failure?
> Shouldn't it only result in the lack of availability of the driver?
IIUC, driver startup is supposed to fail only on serious errors, such as
ENOMEM. But it doesn't really matter anymore since I realized there's a better
fix for this issue. Instead of not adding deviceboot flag to guest
capabilities, we should rather ignore qemu binary for which we are not able to
extract version info and don't put it into guest capabilities at all. I've
sent a patch for that, which obsoletes this patch.
Jirka
From eblake at redhat.com Mon Apr 4 22:23:23 2011
From: eblake at redhat.com (Eric Blake)
Date: Mon, 04 Apr 2011 16:23:23 -0600
Subject: [libvirt] [PATCH] qemu: Ignore unusable binaries
In-Reply-To:
References:
Message-ID: <4D9A44DB.1080802@redhat.com>
On 04/04/2011 04:08 PM, Jiri Denemark wrote:
> When initializing qemu guest capabilities, we should ignore qemu
> binaries that we are not able to extract version/help info from since
> they will be unusable for creating domains anyway. Ignoring them is also
> much better than letting initialization of qemu driver fail.
> ---
> src/qemu/qemu_capabilities.c | 11 ++++++++---
> 1 files changed, 8 insertions(+), 3 deletions(-)
ACK.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From eblake at redhat.com Mon Apr 4 22:39:39 2011
From: eblake at redhat.com (Eric Blake)
Date: Mon, 04 Apr 2011 16:39:39 -0600
Subject: [libvirt] [PATCH] Allow relative path for qemu backing file
In-Reply-To: <1301275814-25480-1-git-send-email-jesse.cook@eads-na-security.com>
References: <1301275814-25480-1-git-send-email-jesse.cook@eads-na-security.com>
Message-ID: <4D9A48AB.2090504@redhat.com>
On 03/27/2011 07:30 PM, Jesse Cook wrote:
> This patch enables the relative backing file path support provided by
> qemu-img create.
>
> If a relative path is specified for the backing file, it is converted
> to an absolute path using the storage pool path. The absolute path is
> used to verify that the backing file exists. If the backing file exists,
> the relative path is allowed and will be provided to qemu-img create.
>
> This patch takes the place of a previous patch:
> http://www.redhat.com/archives/libvir-list/2011-March/msg00179.html
> ---
> src/storage/storage_backend.c | 18 +++++++++++++++++-
> 1 files changed, 17 insertions(+), 1 deletions(-)
Sorry for not reviewing this in time for 0.9.0.
> @@ -686,7 +689,20 @@ virStorageBackendCreateQemuImg(virConnectPtr conn,
> vol->backingStore.format);
> return -1;
> }
> - if (access(vol->backingStore.path, R_OK) != 0) {
> +
> + /* Convert relative backing store paths to absolute paths for access
> + * validation.
> + */
> + if ('/' != *(vol->backingStore.path)) {
> + virAsprintf(&absolutePath, "%s/%s", pool->def->target.path,
> + vol->backingStore.path);
> +
> + } else {
> + virAsprintf(&absolutePath, "%s", vol->backingStore.path);
strdup is more efficient here, and avoiding malloc in the first place
even more so.
> + }
> + accessRetCode = access(absolutePath, R_OK);
This could segfault on OOM.
> + VIR_FREE(absolutePath);
> + if (accessRetCode != 0) {
> virReportSystemError(errno,
> _("inaccessible backing store volume %s"),
> vol->backingStore.path);
ACK with nits fixed; so here's what I squashed in before pushing. I
also updated AUTHORS to pass 'make syntax-check'; feel free to let me
know off-list if you prefer any alternate spelling there (especially
since you sent v1 and v2 under different email aliases).
diff --git i/src/storage/storage_backend.c w/src/storage/storage_backend.c
index 5f5565b..8af2878 100644
--- i/src/storage/storage_backend.c
+++ w/src/storage/storage_backend.c
@@ -693,7 +693,6 @@ virStorageBackendCreateQemuImg(virConnectPtr conn,
if (vol->backingStore.path) {
int accessRetCode = -1;
-
char *absolutePath = NULL;
/* XXX: Not strictly required: qemu-img has an option a different
@@ -719,14 +718,14 @@ virStorageBackendCreateQemuImg(virConnectPtr conn,
/* Convert relative backing store paths to absolute paths for
access
* validation.
*/
- if ('/' != *(vol->backingStore.path)) {
+ if ('/' != *(vol->backingStore.path) &&
virAsprintf(&absolutePath, "%s/%s", pool->def->target.path,
- vol->backingStore.path);
-
- } else {
- virAsprintf(&absolutePath, "%s", vol->backingStore.path);
+ vol->backingStore.path) < 0) {
+ virReportOOMError();
+ return -1;
}
- accessRetCode = access(absolutePath, R_OK);
+ accessRetCode = access(absolutePath ? absolutePath
+ : vol->backingStore.path, R_OK);
VIR_FREE(absolutePath);
if (accessRetCode != 0) {
virReportSystemError(errno,
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From eblake at redhat.com Mon Apr 4 22:43:01 2011
From: eblake at redhat.com (Eric Blake)
Date: Mon, 04 Apr 2011 16:43:01 -0600
Subject: [libvirt] [PATCH 1/3] remove devices from
driver->activePciHostdevs when qemuPrepareHostdevPCIDevices() failed
In-Reply-To: <4D90323A.2040508@cn.fujitsu.com>
References: <4D90306A.6060805@cn.fujitsu.com> <4D90323A.2040508@cn.fujitsu.com>
Message-ID: <4D9A4975.20202@redhat.com>
On 03/28/2011 01:01 AM, Wen Congyang wrote:
> We should not mark pci devices as active when qemuPrepareHostdevPCIDevices()
> failed.
>
> ---
> src/qemu/qemu_hostdev.c | 21 ++++++++++++++++++---
> 1 files changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
> index f4b2108..30db0e2 100644
> --- a/src/qemu/qemu_hostdev.c
> +++ b/src/qemu/qemu_hostdev.c
> @@ -112,7 +112,7 @@ int qemuPrepareHostdevPCIDevices(struct qemud_driver *driver,
> if (!(pcidevs = qemuGetPciHostDeviceList(hostdevs, nhostdevs)))
> return -1;
>
> - /* We have to use 3 loops here. *All* devices must
> + /* We have to use 4 loops here. *All* devices must
ACK.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From eblake at redhat.com Mon Apr 4 22:53:49 2011
From: eblake at redhat.com (Eric Blake)
Date: Mon, 04 Apr 2011 16:53:49 -0600
Subject: [libvirt] [PATCH 2/3] reattach pci device
when pciBindDeviceToStub() failed
In-Reply-To: <4D90323D.4000008@cn.fujitsu.com>
References: <4D90306A.6060805@cn.fujitsu.com> <4D90323D.4000008@cn.fujitsu.com>
Message-ID: <4D9A4BFD.8090405@redhat.com>
On 03/28/2011 01:01 AM, Wen Congyang wrote:
> We should bind pci device to original driver when pciBindDeviceToStub() failed.
> If the pci device is not bound to any driver before calling pciBindDeviceToStub(),
> we should only unbind it from pci-stub. If it is bound to pci-stub, we should not
> unbid it from pci-stub.
>
> ---
> src/util/pci.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++++------
> 1 files changed, 80 insertions(+), 10 deletions(-)
>
> diff --git a/src/util/pci.c b/src/util/pci.c
> index 8d2dbb0..e30f5cf 100644
> --- a/src/util/pci.c
> +++ b/src/util/pci.c
> @@ -65,6 +65,11 @@ struct _pciDevice {
> unsigned has_flr : 1;
> unsigned has_pm_reset : 1;
> unsigned managed : 1;
> +
> + /* used by reattach function */
> + unsigned unbind_from_stub : 1;
> + unsigned remove_slot : 1;
> + unsigned reprobe : 1;
> };
>
> struct _pciDeviceList {
> @@ -834,11 +839,25 @@ recheck:
> }
>
>
> +static int pciUnBindDeviceFromStub(pciDevice *dev, const char *driver);
I would have used Unbind rather than UnBind, but that's cosmetic. Is it
possible to float that function up, instead of having to have a forward
declaration? I tend to topologically sort my static functions when
possible (again, cosmetic).
> static int
> pciBindDeviceToStub(pciDevice *dev, const char *driver)
> {
> char drvdir[PATH_MAX];
> char path[PATH_MAX];
> + int reprobe = 0;
> + int ret = 0;
> +
> + /* check whether the device is already bound to a driver */
> + pciDriverDir(drvdir, sizeof(drvdir), driver);
> + pciDeviceFile(path, sizeof(path), dev->name, "driver");
Ouch - conflict with Matthias's patches to avoid PATH_MAX. If that goes
in first, your rebase might not be trivial, so it would be worth a v2.
But overall, I think the idea of this patch is sane, and nothing obvious
jumped out at me as needing fixing other than rebase issues.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From eblake at redhat.com Mon Apr 4 22:54:54 2011
From: eblake at redhat.com (Eric Blake)
Date: Mon, 04 Apr 2011 16:54:54 -0600
Subject: [libvirt] [PATCH 3/3] reattach pci devices when
qemuPrepareHostdevPCIDevices() failed
In-Reply-To: <4D90323F.1020105@cn.fujitsu.com>
References: <4D90306A.6060805@cn.fujitsu.com> <4D90323F.1020105@cn.fujitsu.com>
Message-ID: <4D9A4C3E.2030003@redhat.com>
On 03/28/2011 01:01 AM, Wen Congyang wrote:
> Reattach all pci devices that we detached when qemuPrepareHostdevPCIDevices()
> failed.
>
> ---
> src/qemu/qemu_hostdev.c | 12 +++++++++---
> 1 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
> index 30db0e2..7f5ad51 100644
> --- a/src/qemu/qemu_hostdev.c
> +++ b/src/qemu/qemu_hostdev.c
> @@ -127,11 +127,11 @@ int qemuPrepareHostdevPCIDevices(struct qemud_driver *driver,
> for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
> pciDevice *dev = pciDeviceListGet(pcidevs, i);
> if (!pciDeviceIsAssignable(dev, !driver->relaxedACS))
> - goto cleanup;
> + goto reattachdevs;
>
> if (pciDeviceGetManaged(dev) &&
> pciDettachDevice(dev, driver->activePciHostdevs) < 0)
> - goto cleanup;
> + goto reattachdevs;
Makes sense; ACK.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From eblake at redhat.com Mon Apr 4 23:28:50 2011
From: eblake at redhat.com (Eric Blake)
Date: Mon, 04 Apr 2011 17:28:50 -0600
Subject: [libvirt] [PATCH] Add autostart support to libxl driver
In-Reply-To: <201103281249.22632.gross@univention.de>
References: <201103281249.22632.gross@univention.de>
Message-ID: <4D9A5432.7030905@redhat.com>
On 03/28/2011 04:49 AM, Markus Gro? wrote:
> This patch is rebased against the patchset from here:
> https://www.redhat.com/archives/libvir-list/2011-March/msg01260.html
> The domainSetAutostart function is nearly identical to the one from qemu.
>
> ---
> src/libxl/libxl_driver.c | 137 ++++++++++++++++++++++++++++++++++++++++++++--
> 1 files changed, 131 insertions(+), 6 deletions(-)
ACK and pushed.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From usui at mxm.nes.nec.co.jp Tue Apr 5 01:11:07 2011
From: usui at mxm.nes.nec.co.jp (Minoru Usui)
Date: Tue, 5 Apr 2011 10:11:07 +0900
Subject: [libvirt] [PATCH 1/6] virNodeGetCpuTime: Expose new API
In-Reply-To:
References: <20110401103833.8b66b57e.usui@mxm.nes.nec.co.jp>
<20110401105548.a78607f7.usui@mxm.nes.nec.co.jp>
<4D95FB08.20802@redhat.com>
<20110404110310.e85d09ba.usui@mxm.nes.nec.co.jp>
<20110404115043.GA13616@redhat.com>
Message-ID: <20110405101107.ec0a1246.usui@mxm.nes.nec.co.jp>
Hi, Daniel, Matthias
Thank you for your comments.
On Mon, 4 Apr 2011 14:30:32 +0200
Matthias Bolte wrote:
> 2011/4/4 Daniel P. Berrange :
> > On Mon, Apr 04, 2011 at 11:03:10AM +0900, Minoru Usui wrote:
> >> Hi, Matthias.
> >>
> >> On Fri, 1 Apr 2011 20:22:17 +0200
> >> Matthias Bolte wrote:
> >>
> >> > 2011/4/1 Eric Blake :
> >> > > On 03/31/2011 07:55 PM, Minoru Usui wrote:
> >> > >> virNodeGetCpuTime: Expose new API
> >> > >>
> >> > >> ?include/libvirt/libvirt.h.in | ? 26 ++++++++++++++++++++++++++
> >> > >> ?src/libvirt_public.syms ? ? ?| ? ?1 +
> >> > >> ?2 files changed, 27 insertions(+), 0 deletions(-)
> >> > >
> >> > >>
> >> > >> +/**
> >> > >> + * virNodeCpuTime:
> >> > >> + *
> >> > >> + * a virNodeCpuTime is a structure filled by virNodeGetCpuTime() and providing
> >> > >> + * the information for the cpu time of Node.
> >> > >> + */
> >> > >> +
> >> > >> +typedef struct _virNodeCpuTime virNodeCpuTime;
> >> > >> +
> >> > >> +struct _virNodeCpuTime {
> >> > >> + ? ?unsigned long long user;
> >> > >> + ? ?unsigned long long system;
> >> > >> + ? ?unsigned long long idle;
> >> > >> + ? ?unsigned long long iowait;
> >> > >> +};
> >> > >
> >> > > Can we portably get all of this information on Windows? ?If not, how do
> >> > > you express which values we don't know how to obtain?
> >> > >
> >> >
> >> > In the context of ESX I vote against this absolute CPU time values.
> >> > ESX provides this values relative to a 20 second timeslots with 1 hour
> >> > of history. This makes it nearly impossible to obtain the absolute CPU
> >> > time. The same problem already exists for the domain's virtual CPU
> >> > time.
> >> >
> >> > When you look at virt-top's usage of the domain's virtual CPU time,
> >> > you see that it actually doesn't really care about the absolute value,
> >> > but deduces the CPU utilization from it. I suggest that we find a
> >> > different representation for this information that is not by
> >> > definition impossible to implement for ESX.
> >> >
> >> > Matthias
> >>
> >> I didn't know ESX couldn't return absolute CPU time value.
> >> Thank you for your comment.
> >>
> >> We really want to get CPU utilization information of the node, not
> >> absolute CPU time values.
> >> But linux doesn't provide CPU utilization directly,
> >> so my patch returns absolute CPU time values,
> >> and CPU utilization is calculated by client which uses new API.
> >>
> >> To return CPU utilization by new API, I think there are two issues of implementing on linux.
> >>
> >> ? a) How much interval does calculate CPU utilization?
> >> ? ? ?To calculate CPU utilization on linux, we need to get absolute CPU time value of the node
> >> ? ? ?from /proc/stat two times.
> >> ? ? ?How much interval properly? 1sec? 1min? or others?
> >
> > The fact that there is the question of what is the right interval
> > demonstrates the inherant flaw in such an API design. Providing
> > the raw absolute time allows an app much more flexiblity in how
> > they work with the data, avoiding the need for such policies in
> > libvirt.
> >
> >> ? b) Can new API wait its interval?
> >> ? ? ?If we select simply implementation, new API waits its interval.
> >> ? ? ?But API user don't want to wait every API calls, if its interval is long.
> >> ? ? ?So I think libvirtd will be calculating CPU utilization in background every interval.
> >> ? ? ?Is this approach OK?
> >
> > IMHO we don't really want libvirtd to be constantly polling & calculating
> > this data, at least not unless an application is currently asking for it.
> > I think we want this API to have the style that is like the current
> > virDomainMemoryStats ?API. Then, we can define a set of parameters that
> > can be fetched, allowing each parameter to be optional
> >
> > eg
> >
> > ?enum {
> > ? ? VIR_NODE_CPU_TIME_KERNEL,
> > ? ? VIR_NODE_CPU_TIME_USER,
> > ? ? VIR_NODE_CPU_TIME_IDLE,
> > ? ? VIR_NODE_CPU_TIME_IOWAIT,
> > ? ? VIR_NODE_CPU_TIME_UTILIZATION,
> > ?};
> >
> > For QEMU we'd provide the first 4 values, allowing apps maximum
> > flexibility in how they calculate utilization over different time
> > periods. For VMWare we'd provide only the last value.
> >
> > An app like virt-manager, can display UTILIZATION value directly if
> > that is present, otherwise it will be able to calculate data from
> > the other times as it does now for domains. So it would work with
> > both QEMU and VMWare, to the best of its abilities.
> >
> > Regards,
> > Daniel
> >
>
> For ESX the driver doesn't even need to calculate a usage/utilization
> value, because the ESX server already does this on it's own and the
> driver can just ask for it. The usage value is in percent and 100%
> represents all CPUs on the server.
>
> I like that approach.
>
> Matthias
OK.
I'll change the user I/F to above one.
--
Minoru Usui
From jfehlig at novell.com Tue Apr 5 04:05:40 2011
From: jfehlig at novell.com (Jim Fehlig)
Date: Mon, 04 Apr 2011 22:05:40 -0600
Subject: [libvirt] [PATCH] Add autostart support to libxl driver
In-Reply-To: <4D9A5432.7030905@redhat.com>
References: <201103281249.22632.gross@univention.de>
<4D9A5432.7030905@redhat.com>
Message-ID: <4D9A9514.9090705@novell.com>
Eric Blake wrote:
> On 03/28/2011 04:49 AM, Markus Gro? wrote:
>
>> This patch is rebased against the patchset from here:
>> https://www.redhat.com/archives/libvir-list/2011-March/msg01260.html
>> The domainSetAutostart function is nearly identical to the one from qemu.
>>
>> ---
>> src/libxl/libxl_driver.c | 137 ++++++++++++++++++++++++++++++++++++++++++++--
>> 1 files changed, 131 insertions(+), 6 deletions(-)
>>
>
> ACK and pushed.
Eric, thanks for the review.
Markus, sorry for the silence on your patch. I've been traveling and
just now catching up on mail.
Regards,
Jim
From amit.shah at redhat.com Tue Apr 5 06:41:20 2011
From: amit.shah at redhat.com (Amit Shah)
Date: Tue, 5 Apr 2011 12:11:20 +0530
Subject: [libvirt] [Qemu-devel] [PATCH v2 3/3] raw-posix: Re-open host
CD-ROM after media change
In-Reply-To:
References: <1301425482-8722-1-git-send-email-stefanha@linux.vnet.ibm.com>
<1301425482-8722-4-git-send-email-stefanha@linux.vnet.ibm.com>
<4D99C61E.3080600@redhat.com> <4D99C9ED.3020602@codemonkey.ws>
<4D99CC74.9070703@redhat.com>
Message-ID: <20110405064120.GB2872@amit-x200.redhat.com>
On (Mon) 04 Apr 2011 [16:09:05], Stefan Hajnoczi wrote:
> On Mon, Apr 4, 2011 at 2:49 PM, Avi Kivity wrote:
> > On 04/04/2011 04:38 PM, Anthony Liguori wrote:
> >>
> >> On 04/04/2011 08:22 AM, Avi Kivity wrote:
> >>>
> >>> On 04/03/2011 02:57 PM, Stefan Hajnoczi wrote:
> >>>>
> >>>> In order for media change to work with Linux host CD-ROM it is
> >>>> necessary to reopen the file (otherwise the inode size will not
> >>>> refresh, this is an issue with existing kernels).
> >>>>
> >>>
> >>> Maybe we should fix the bug in Linux (and backport as necessary)?
> >>>
> >>> I think cd-rom assignment is sufficiently obscure that we can require a
> >>> fixed kernel instead of providing a workaround.
> >>
> >> Do reads fail after CD change? ?Or do they succeed and the size is just
> >> reported incorrectly?
> >>
> >> If it's the later, I'd agree that it needs fixing in the kernel. ?If it's
> >> the former, I'd say it's clearly a feature.
> >>
> >
> > Even if it's a documented or intentional feature, we can add an ioctl to
> > "refresh" the device with up-to-date data.
>
> It's possible to fix this in the kernel. I just haven't written the
> patch yet. The inode size needs to be updated when the new medium is
> detected.
>
> I haven't tested but I suspect reads within the size of the previous
> medium will succeed. But if the new medium is larger then reads
> beyond the old medium size will fail.
See http://www.spinics.net/lists/linux-scsi/msg51504.html
Amit
From jyang at redhat.com Tue Apr 5 06:47:22 2011
From: jyang at redhat.com (Osier Yang)
Date: Tue, 5 Apr 2011 14:47:22 +0800
Subject: [libvirt] [PATCH] qemu: Do not unlink managedsave image if
restoring fails.
Message-ID: <1301986042-13725-1-git-send-email-jyang@redhat.com>
Both "qemuDomainStartWithFlags" and "qemuAutostartDomain" try to
restore the domain from managedsave'ed image if it exists (by
invoking "qemuDomainObjRestore"), but it unlinks the image even
if restoring fails, which causes data loss.
However, I'm not sure if it's the very correct way to fix it,
if restoring fails, and we didn't remove the image, it will
trys to restore from the image again next time, if that's
not the user expected (e.g. the user made quite many changes
on the guest), then it's a new problem.
---
src/qemu/qemu_driver.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 48fe266..22c29e4 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3423,18 +3423,20 @@ static int qemudDomainObjStart(virConnectPtr conn,
/*
* If there is a managed saved state restore it instead of starting
- * from scratch. In any case the old state is removed.
+ * from scratch.
*/
managed_save = qemuDomainManagedSavePath(driver, vm);
if ((managed_save) && (virFileExists(managed_save))) {
ret = qemuDomainObjRestore(conn, driver, vm, managed_save);
- if (unlink(managed_save) < 0) {
- VIR_WARN("Failed to remove the managed state %s", managed_save);
- }
+ if (ret == 0) {
+ if (unlink(managed_save) < 0)
+ VIR_WARN("Failed to remove the managed state %s", managed_save);
- if (ret == 0)
goto cleanup;
+ } else {
+ VIR_WARN("Failed to restore from the managed state %s", managed_save);
+ }
}
ret = qemuProcessStart(conn, driver, vm, NULL, start_paused, -1, NULL,
--
1.7.4
From matthias.bolte at googlemail.com Tue Apr 5 06:49:28 2011
From: matthias.bolte at googlemail.com (Matthias Bolte)
Date: Tue, 5 Apr 2011 08:49:28 +0200
Subject: [libvirt] [PATCH] vmx: Support persistent CPU shares
In-Reply-To: <4D9A0042.8030805@redhat.com>
References: <20110403124355.GA22943@sbox> <20110404030541.GQ24385@redhat.com>
<4D9A0042.8030805@redhat.com>
Message-ID:
2011/4/4 Eric Blake :
> On 04/04/2011 12:28 AM, Matthias Bolte wrote:
>> 2011/4/4 Daniel Veillard :
>>> On Sun, Apr 03, 2011 at 02:43:55PM +0200, Matthias Bolte wrote:
>>
>>>
>>> ?ACK, while nice, it may be a bit late for 0.9.0, okay to wait for the
>>> next cycle ? We already have this for xen and qemu, seeing it for ESX
>>> confirms the design is fine, which is the most important from my point
>>> of vue :-)
>>>
>>> Daniel
>>>
>>
>> Sure, this can wait until 0.9.1. On the ESX side the shares value is
>> persistent anyway. This patch just exposes it as persistent in libvirt
>> too.
>
> 0.9.1 is now started, so feel free to push now :)
>
Pushed, thanks.
Matthias
From matthias.bolte at googlemail.com Tue Apr 5 06:50:06 2011
From: matthias.bolte at googlemail.com (Matthias Bolte)
Date: Tue, 5 Apr 2011 08:50:06 +0200
Subject: [libvirt] [PATCH] vmx: Use case-insensitive compare functions
for all content
In-Reply-To: <20110404030237.GP24385@redhat.com>
References: <20110403121914.GA22826@sbox> <20110404030237.GP24385@redhat.com>
Message-ID:
2011/4/4 Daniel Veillard :
> On Sun, Apr 03, 2011 at 02:19:14PM +0200, Matthias Bolte wrote:
>> ---
>> ?src/vmx/vmx.c | ? 10 +++++-----
>> ?1 files changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
>> index 9f4d5fb..9a482ef 100644
>> --- a/src/vmx/vmx.c
>> +++ b/src/vmx/vmx.c
>> @@ -730,7 +730,7 @@ virVMXGetConfigLong(virConfPtr conf, const char *name, long long *number,
>> ? ? ? ? ? ? ?}
>> ? ? ? ? ?}
>>
>> - ? ? ? ?if (STREQ(value->str, "unlimited")) {
>> + ? ? ? ?if (STRCASEEQ(value->str, "unlimited")) {
>> ? ? ? ? ? ? ?*number = -1;
>> ? ? ? ? ?} else if (virStrToLong_ll(value->str, NULL, 10, number) < 0) {
>> ? ? ? ? ? ? ?VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
>> @@ -1385,7 +1385,7 @@ virVMXParseConfig(virVMXContext *ctx, virCapsPtr caps, const char *vmx)
>> ? ? ? ? ?goto cleanup;
>> ? ? ?}
>>
>> - ? ?if (sched_cpu_affinity != NULL && STRNEQ(sched_cpu_affinity, "all")) {
>> + ? ?if (sched_cpu_affinity != NULL && STRCASENEQ(sched_cpu_affinity, "all")) {
>> ? ? ? ? ?const char *current = sched_cpu_affinity;
>> ? ? ? ? ?int number, count = 0;
>>
>> @@ -2107,7 +2107,7 @@ virVMXParseDisk(virVMXContext *ctx, virCapsPtr caps, virConfPtr conf,
>> ? ? ? ? ? ? ? ? ?goto cleanup;
>> ? ? ? ? ? ? ?}
>> ? ? ? ? ?} else if (virFileHasSuffix(fileName, ".iso") ||
>> - ? ? ? ? ? ? ? ? ? STREQ(deviceType, "atapi-cdrom")) {
>> + ? ? ? ? ? ? ? ? ? STRCASEEQ(deviceType, "atapi-cdrom")) {
>> ? ? ? ? ? ? ?/*
>> ? ? ? ? ? ? ? * This function was called in order to parse a harddisk device,
>> ? ? ? ? ? ? ? * but .iso files and 'atapi-cdrom' devices are for CDROM devices
>> @@ -2146,7 +2146,7 @@ virVMXParseDisk(virVMXContext *ctx, virCapsPtr caps, virConfPtr conf,
>> ? ? ? ? ? ? ? * handle it.
>> ? ? ? ? ? ? ? */
>> ? ? ? ? ? ? ?goto ignore;
>> - ? ? ? ?} else if (STREQ(deviceType, "atapi-cdrom")) {
>> + ? ? ? ?} else if (STRCASEEQ(deviceType, "atapi-cdrom")) {
>> ? ? ? ? ? ? ?(*def)->type = VIR_DOMAIN_DISK_TYPE_BLOCK;
>> ? ? ? ? ? ? ?(*def)->src = fileName;
>>
>> @@ -2174,7 +2174,7 @@ virVMXParseDisk(virVMXContext *ctx, virCapsPtr caps, virConfPtr conf,
>> ? ? ? ? ? ? ?if ((*def)->src == NULL) {
>> ? ? ? ? ? ? ? ? ?goto cleanup;
>> ? ? ? ? ? ? ?}
>> - ? ? ? ?} else if (fileType != NULL && STREQ(fileType, "device")) {
>> + ? ? ? ?} else if (fileType != NULL && STRCASEEQ(fileType, "device")) {
>> ? ? ? ? ? ? ?(*def)->type = VIR_DOMAIN_DISK_TYPE_BLOCK;
>> ? ? ? ? ? ? ?(*def)->src = fileName;
>
> ?Sounds fine to me but would you categorize this as bug fix (for 0.9.0)
> or rather an improvement and wait. I guess it depends how you ended up
> crossing this, and I can't guess it :-)
>
> Daniel
>
There was a bug report a while ago about the VMX parser being
case-sensitive, but the .vmx files actually being case-insensitive.
The initial fix was incomplete and I just came across this remaining
case-sensitive compares while adding persistent CPU shares.
As 0.9.0 is out of the door now, I pushed it.
Matthias
From mprivozn at redhat.com Tue Apr 5 07:27:41 2011
From: mprivozn at redhat.com (=?ISO-8859-1?Q?Michal_Pr=EDvozn=EDk?=)
Date: Tue, 05 Apr 2011 09:27:41 +0200
Subject: [libvirt] [PATCH] virsh: Increase device-detach intelligence
In-Reply-To: <4D9A42A8.1040206@redhat.com>
References: <1301065746-12468-1-git-send-email-mprivozn@redhat.com>
<4D9A42A8.1040206@redhat.com>
Message-ID: <4D9AC46D.9070604@redhat.com>
On 04/05/2011 12:14 AM, Eric Blake wrote:
> On 03/25/2011 09:09 AM, Michal Privoznik wrote:
>> Up to now users have to give a full XML description on input when
>> device-detaching. If they omited something it lead to unclear
>> error messages (like generated MAC wasn't found, etc.).
>> With this patch users can specify only those information which
>> specify one device sufficiently precise. Remaining information is
>> completed from domain.
>> ---
>> tools/virsh.c | 260 +++++++++++++++++++++++++++++++++++++++++++++++++++++----
>> 1 files changed, 245 insertions(+), 15 deletions(-)
>
> Not forgotten, but not quite yet to the top of my queue, either :( I
> guess having too many patches to review is a good sign that there is a
> lot of contribution going on.
>
>>
>> diff --git a/tools/virsh.c b/tools/virsh.c
>> index 50ca50f..95d27f7 100644
>> --- a/tools/virsh.c
>> +++ b/tools/virsh.c
>> @@ -8702,6 +8702,224 @@ cmdAttachDevice(vshControl *ctl, const vshCmd *cmd)
>> return TRUE;
>> }
>>
>> +/**
>> + * Check if n1 is superset of n2, meaning n1 contains all elements and
>> + * attributes as n2 at lest. Including children.
>> + * @n1 first node
>> + * @n2 second node
>> + * return 1 in case n1 covers n2, 0 otherwise.
>> + */
>> +static int
>> +vshNodeIsSuperset(xmlNodePtr n1, xmlNodePtr n2) {
>
> Are there any xml library functions that can already do this without you
> rewriting it from scratch?
No, there are not. I consulted this issue with Daniel Veillard.
>
>> +/**
>> + * To given domain and (probably incomplete) device XML specification try to
>> + * find such device in domain and complete missing parts. This is however
>> + * possible when given device XML is sufficiently precise so it addresses only
>> + * one device.
>> + * @ctl vshControl for error messages printing
>> + * @dom domain
>> + * @oldXML device XML before
>> + * @newXML and after completion
>> + * Returns -2 when no such device exists in domain, -3 when given XML selects many
>> + * (is too ambiguous), 0 in case of success. Otherwise returns -1. @newXML
>> + * is touched only in case of success.
>> + */
>> +static int
>> +vshCompleteXMLFromDomain(vshControl *ctl, virDomainPtr dom, char *oldXML,
>> + char **newXML) {
>
> My quick glance of just the documentation says that this looks like a
> nice helper, but I haven't reviewed it in depth.
>
From matthias.bolte at googlemail.com Tue Apr 5 07:36:36 2011
From: matthias.bolte at googlemail.com (Matthias Bolte)
Date: Tue, 5 Apr 2011 09:36:36 +0200
Subject: [libvirt] [PATCH 00/20] Remove large stack allocations
In-Reply-To: <20110404104423.GW13616@redhat.com>
References: <1301822493-23013-1-git-send-email-matthias.bolte@googlemail.com>
<20110404104423.GW13616@redhat.com>
Message-ID:
2011/4/4 Daniel P. Berrange :
> On Sun, Apr 03, 2011 at 11:21:13AM +0200, Matthias Bolte wrote:
>> This is meant for post-0.9.0.
>>
>> The series removes many large stack allocations from the code base and makes
>> it compile with -Wframe-larger-than=2500. This was inspired by Dan's patch for
>> using gnulib's manywarnings & warnings modules [1]. Where he mentioned that
>> currently -Wframe-larger-than=20480 is required.
>>
>> This series doesn't address stack usage in the test suite.
>
> I've ACKd most of the patches - feel free to push those after the release
> & just repost the couple which had comments, rather than the whole series.
>
> Daniel
>
Okay, I removed the TODO comments from 09/20 and pushed the series
expect 11/20 and 16/20.
Matthias
From avi at redhat.com Tue Apr 5 07:48:16 2011
From: avi at redhat.com (Avi Kivity)
Date: Tue, 05 Apr 2011 10:48:16 +0300
Subject: [libvirt] [Qemu-devel] [PATCH v2 3/3] raw-posix: Re-open host
CD-ROM after media change
In-Reply-To: <20110405064120.GB2872@amit-x200.redhat.com>
References: <1301425482-8722-1-git-send-email-stefanha@linux.vnet.ibm.com>
<1301425482-8722-4-git-send-email-stefanha@linux.vnet.ibm.com>
<4D99C61E.3080600@redhat.com> <4D99C9ED.3020602@codemonkey.ws>
<4D99CC74.9070703@redhat.com>
<20110405064120.GB2872@amit-x200.redhat.com>
Message-ID: <4D9AC940.5000502@redhat.com>
On 04/05/2011 09:41 AM, Amit Shah wrote:
> See http://www.spinics.net/lists/linux-scsi/msg51504.html
I see this is quite fresh. What are the plans here?
--
error compiling committee.c: too many arguments to function
From amit.shah at redhat.com Tue Apr 5 08:09:00 2011
From: amit.shah at redhat.com (Amit Shah)
Date: Tue, 5 Apr 2011 13:39:00 +0530
Subject: [libvirt] [Qemu-devel] [PATCH v2 3/3] raw-posix: Re-open host
CD-ROM after media change
In-Reply-To: <4D9AC940.5000502@redhat.com>
References: <1301425482-8722-1-git-send-email-stefanha@linux.vnet.ibm.com>
<1301425482-8722-4-git-send-email-stefanha@linux.vnet.ibm.com>
<4D99C61E.3080600@redhat.com> <4D99C9ED.3020602@codemonkey.ws>
<4D99CC74.9070703@redhat.com>
<20110405064120.GB2872@amit-x200.redhat.com>
<4D9AC940.5000502@redhat.com>
Message-ID: <20110405080900.GE2872@amit-x200.redhat.com>
On (Tue) 05 Apr 2011 [10:48:16], Avi Kivity wrote:
> On 04/05/2011 09:41 AM, Amit Shah wrote:
> >See http://www.spinics.net/lists/linux-scsi/msg51504.html
>
> I see this is quite fresh. What are the plans here?
We're still discussing where the fix should be, but it certainly is a
kernel bug and should be fixed there, and then applied to stable.
However, there are other bugs in qemu which will prevent the right
size changes to be visible in the guest (the RFC series I sent out
earlier in this thread need to be applied to QEMU at the least, the
series has grown in my development tree since the time I sent that one
out). So essentially we need to update both, the hypervisor and the
guest to get proper CDROM media change support.
It also looks like we can't have a workaround in QEMU to get older
guests to work.
However, a hack in the kernel can be used without any QEMU changes
(revalidate disk on each sr_open() call, irrespective of detecting any
media change). I'm against doing that for upstream, but downstreams
could do that for new guest - old hypervisor compat.
Amit
From stefanha at gmail.com Tue Apr 5 08:40:05 2011
From: stefanha at gmail.com (Stefan Hajnoczi)
Date: Tue, 5 Apr 2011 09:40:05 +0100
Subject: [libvirt] [Qemu-devel] [PATCH v2 3/3] raw-posix: Re-open host
CD-ROM after media change
In-Reply-To: <20110405064120.GB2872@amit-x200.redhat.com>
References: <1301425482-8722-1-git-send-email-stefanha@linux.vnet.ibm.com>
<1301425482-8722-4-git-send-email-stefanha@linux.vnet.ibm.com>
<4D99C61E.3080600@redhat.com> <4D99C9ED.3020602@codemonkey.ws>
<4D99CC74.9070703@redhat.com>
<20110405064120.GB2872@amit-x200.redhat.com>
Message-ID:
On Tue, Apr 5, 2011 at 7:41 AM, Amit Shah wrote:
> On (Mon) 04 Apr 2011 [16:09:05], Stefan Hajnoczi wrote:
>> On Mon, Apr 4, 2011 at 2:49 PM, Avi Kivity wrote:
>> > On 04/04/2011 04:38 PM, Anthony Liguori wrote:
>> >>
>> >> On 04/04/2011 08:22 AM, Avi Kivity wrote:
>> >>>
>> >>> On 04/03/2011 02:57 PM, Stefan Hajnoczi wrote:
>> >>>>
>> >>>> In order for media change to work with Linux host CD-ROM it is
>> >>>> necessary to reopen the file (otherwise the inode size will not
>> >>>> refresh, this is an issue with existing kernels).
>> >>>>
>> >>>
>> >>> Maybe we should fix the bug in Linux (and backport as necessary)?
>> >>>
>> >>> I think cd-rom assignment is sufficiently obscure that we can require a
>> >>> fixed kernel instead of providing a workaround.
>> >>
>> >> Do reads fail after CD change? ?Or do they succeed and the size is just
>> >> reported incorrectly?
>> >>
>> >> If it's the later, I'd agree that it needs fixing in the kernel. ?If it's
>> >> the former, I'd say it's clearly a feature.
>> >>
>> >
>> > Even if it's a documented or intentional feature, we can add an ioctl to
>> > "refresh" the device with up-to-date data.
>>
>> It's possible to fix this in the kernel. ?I just haven't written the
>> patch yet. ?The inode size needs to be updated when the new medium is
>> detected.
>>
>> I haven't tested but I suspect reads within the size of the previous
>> medium will succeed. ?But if the new medium is larger then reads
>> beyond the old medium size will fail.
>
> See http://www.spinics.net/lists/linux-scsi/msg51504.html
I don't think that patch updates the block inode size. We'd need to
call fs/block_dev.c:revalidate_disk() instead of directly calling
cdi->disk->fops->revalidate_disk(cdi->disk).
fs/block_dev.c:revalidate_disk() calls check_disk_size_change(), which
will update the inode size.
Here are the steps to reproduce the issue: https://lkml.org/lkml/2011/3/23/156
Stefan
From amit.shah at redhat.com Tue Apr 5 08:58:32 2011
From: amit.shah at redhat.com (Amit Shah)
Date: Tue, 5 Apr 2011 14:28:32 +0530
Subject: [libvirt] [Qemu-devel] [PATCH v2 3/3] raw-posix: Re-open host
CD-ROM after media change
In-Reply-To:
References: <1301425482-8722-1-git-send-email-stefanha@linux.vnet.ibm.com>
<1301425482-8722-4-git-send-email-stefanha@linux.vnet.ibm.com>
<4D99C61E.3080600@redhat.com> <4D99C9ED.3020602@codemonkey.ws>
<4D99CC74.9070703@redhat.com>
<20110405064120.GB2872@amit-x200.redhat.com>
Message-ID: <20110405085832.GA27661@amit-x200.redhat.com>
On (Tue) 05 Apr 2011 [09:40:05], Stefan Hajnoczi wrote:
> > See http://www.spinics.net/lists/linux-scsi/msg51504.html
>
> I don't think that patch updates the block inode size. We'd need to
> call fs/block_dev.c:revalidate_disk() instead of directly calling
> cdi->disk->fops->revalidate_disk(cdi->disk).
> fs/block_dev.c:revalidate_disk() calls check_disk_size_change(), which
> will update the inode size.
Then the patch is buggy :-) As Tejun also says in the thread, the
patch should be in the block layer, not sr.c.
(btw that patch does update /sys/block/sr0/size, so that part of
revalidation is done.)
Amit
From avi at redhat.com Tue Apr 5 09:00:38 2011
From: avi at redhat.com (Avi Kivity)
Date: Tue, 05 Apr 2011 12:00:38 +0300
Subject: [libvirt] [Qemu-devel] [PATCH v2 3/3] raw-posix: Re-open host
CD-ROM after media change
In-Reply-To: <20110405080900.GE2872@amit-x200.redhat.com>
References: <1301425482-8722-1-git-send-email-stefanha@linux.vnet.ibm.com>
<1301425482-8722-4-git-send-email-stefanha@linux.vnet.ibm.com>
<4D99C61E.3080600@redhat.com> <4D99C9ED.3020602@codemonkey.ws>
<4D99CC74.9070703@redhat.com>
<20110405064120.GB2872@amit-x200.redhat.com>
<4D9AC940.5000502@redhat.com>
<20110405080900.GE2872@amit-x200.redhat.com>
Message-ID: <4D9ADA36.8040306@redhat.com>
On 04/05/2011 11:09 AM, Amit Shah wrote:
> On (Tue) 05 Apr 2011 [10:48:16], Avi Kivity wrote:
> > On 04/05/2011 09:41 AM, Amit Shah wrote:
> > >See http://www.spinics.net/lists/linux-scsi/msg51504.html
> >
> > I see this is quite fresh. What are the plans here?
>
> We're still discussing where the fix should be, but it certainly is a
> kernel bug and should be fixed there, and then applied to stable.
>
> However, there are other bugs in qemu which will prevent the right
> size changes to be visible in the guest (the RFC series I sent out
> earlier in this thread need to be applied to QEMU at the least, the
> series has grown in my development tree since the time I sent that one
> out). So essentially we need to update both, the hypervisor and the
> guest to get proper CDROM media change support.
Why do we need to update the guest for a qemu bug? What is the qemu bug?
> It also looks like we can't have a workaround in QEMU to get older
> guests to work.
Older guests? or older hosts?
> However, a hack in the kernel can be used without any QEMU changes
> (revalidate disk on each sr_open() call, irrespective of detecting any
> media change). I'm against doing that for upstream, but downstreams
> could do that for new guest - old hypervisor compat.
Seriously confused. Please use the kernels "host kernel" and "qemu"
instead of "hypervisor" which is ambiguous.
--
error compiling committee.c: too many arguments to function
From amit.shah at redhat.com Tue Apr 5 09:12:03 2011
From: amit.shah at redhat.com (Amit Shah)
Date: Tue, 5 Apr 2011 14:42:03 +0530
Subject: [libvirt] [Qemu-devel] [PATCH v2 3/3] raw-posix: Re-open host
CD-ROM after media change
In-Reply-To: <4D9ADA36.8040306@redhat.com>
References: <1301425482-8722-4-git-send-email-stefanha@linux.vnet.ibm.com>
<4D99C61E.3080600@redhat.com> <4D99C9ED.3020602@codemonkey.ws>
<4D99CC74.9070703@redhat.com>
<20110405064120.GB2872@amit-x200.redhat.com>
<4D9AC940.5000502@redhat.com>
<20110405080900.GE2872@amit-x200.redhat.com>
<4D9ADA36.8040306@redhat.com>
Message-ID: <20110405091203.GC27661@amit-x200.redhat.com>
On (Tue) 05 Apr 2011 [12:00:38], Avi Kivity wrote:
> On 04/05/2011 11:09 AM, Amit Shah wrote:
> >On (Tue) 05 Apr 2011 [10:48:16], Avi Kivity wrote:
> >> On 04/05/2011 09:41 AM, Amit Shah wrote:
> >> >See http://www.spinics.net/lists/linux-scsi/msg51504.html
> >>
> >> I see this is quite fresh. What are the plans here?
> >
> >We're still discussing where the fix should be, but it certainly is a
> >kernel bug and should be fixed there, and then applied to stable.
> >
> >However, there are other bugs in qemu which will prevent the right
> >size changes to be visible in the guest (the RFC series I sent out
> >earlier in this thread need to be applied to QEMU at the least, the
> >series has grown in my development tree since the time I sent that one
> >out). So essentially we need to update both, the hypervisor and the
> >guest to get proper CDROM media change support.
>
> Why do we need to update the guest for a qemu bug? What is the qemu bug?
Guest kernel bug: CDROM change event missed, so the the revalidate
call isn't made, which causes stale data (like disc size) to be used
on newer media.
qemu bug: We don't handle the GET_EVENT_STATUS_NOTIFICATION command
from guests (which is a mandatory command acc. to scsi spec) which the
guest uses to detect CDROM changes. Once this command is implemented,
QEMU sends the required info the guest needs to detect CDROM changes.
I have this implemented locally (also sent as RFC PATCH 2/3 in the
'cdrom bug roundup' thread.
So: even if qemu is updated to handle this command, the guest won't
work correctly since it misses the event.
> >It also looks like we can't have a workaround in QEMU to get older
> >guests to work.
>
> Older guests? or older hosts?
Older guests (not patched with fix for the bug described above).
Since the guest kernel completely misses the disc change event in the
path that does the revalidation, there's nothing qemu can do that will
make such older guests notice disc change.
Also: if only the guest kernel is updated by qemu is not, things still
won't work since qemu will never send valid information for the
GET_EVENT_STATUS_NOTIFICATION command.
> >However, a hack in the kernel can be used without any QEMU changes
> >(revalidate disk on each sr_open() call, irrespective of detecting any
> >media change). I'm against doing that for upstream, but downstreams
> >could do that for new guest - old hypervisor compat.
>
> Seriously confused. Please use the kernels "host kernel" and "qemu"
> instead of "hypervisor" which is ambiguous.
OK: this last bit says that forcefully revalidating discs in the guest
kernel when a guest userspace opens the disc will ensure size changes
are reflected properly for guest userspace. So in this case, even if
we're using an older qemu which doesn't implement
GET_EVENT_STATUS_NOTIFICATION, guest userspace apps will work fine.
This is obviously a hack.
Amit
From avi at redhat.com Tue Apr 5 09:17:30 2011
From: avi at redhat.com (Avi Kivity)
Date: Tue, 05 Apr 2011 12:17:30 +0300
Subject: [libvirt] [Qemu-devel] [PATCH v2 3/3] raw-posix: Re-open host
CD-ROM after media change
In-Reply-To: <20110405091203.GC27661@amit-x200.redhat.com>
References: <1301425482-8722-4-git-send-email-stefanha@linux.vnet.ibm.com>
<4D99C61E.3080600@redhat.com> <4D99C9ED.3020602@codemonkey.ws>
<4D99CC74.9070703@redhat.com>
<20110405064120.GB2872@amit-x200.redhat.com>
<4D9AC940.5000502@redhat.com>
<20110405080900.GE2872@amit-x200.redhat.com>
<4D9ADA36.8040306@redhat.com>
<20110405091203.GC27661@amit-x200.redhat.com>
Message-ID: <4D9ADE2A.2020201@redhat.com>
On 04/05/2011 12:12 PM, Amit Shah wrote:
> On (Tue) 05 Apr 2011 [12:00:38], Avi Kivity wrote:
> > On 04/05/2011 11:09 AM, Amit Shah wrote:
> > >On (Tue) 05 Apr 2011 [10:48:16], Avi Kivity wrote:
> > >> On 04/05/2011 09:41 AM, Amit Shah wrote:
> > >> >See http://www.spinics.net/lists/linux-scsi/msg51504.html
> > >>
> > >> I see this is quite fresh. What are the plans here?
> > >
> > >We're still discussing where the fix should be, but it certainly is a
> > >kernel bug and should be fixed there, and then applied to stable.
> > >
> > >However, there are other bugs in qemu which will prevent the right
> > >size changes to be visible in the guest (the RFC series I sent out
> > >earlier in this thread need to be applied to QEMU at the least, the
> > >series has grown in my development tree since the time I sent that one
> > >out). So essentially we need to update both, the hypervisor and the
> > >guest to get proper CDROM media change support.
> >
> > Why do we need to update the guest for a qemu bug? What is the qemu bug?
>
> Guest kernel bug: CDROM change event missed, so the the revalidate
> call isn't made, which causes stale data (like disc size) to be used
> on newer media.
>
> qemu bug: We don't handle the GET_EVENT_STATUS_NOTIFICATION command
> from guests (which is a mandatory command acc. to scsi spec) which the
> guest uses to detect CDROM changes. Once this command is implemented,
> QEMU sends the required info the guest needs to detect CDROM changes.
> I have this implemented locally (also sent as RFC PATCH 2/3 in the
> 'cdrom bug roundup' thread.
>
> So: even if qemu is updated to handle this command, the guest won't
> work correctly since it misses the event.
Okay. We aren't responsible for guest kernel bugs, especially those
which apply to real hardware (we should make more effort for virtio
bugs). It's enough that we fix qemu here.
> > >It also looks like we can't have a workaround in QEMU to get older
> > >guests to work.
> >
> > Older guests? or older hosts?
>
> Older guests (not patched with fix for the bug described above).
>
> Since the guest kernel completely misses the disc change event in the
> path that does the revalidation, there's nothing qemu can do that will
> make such older guests notice disc change.
>
> Also: if only the guest kernel is updated by qemu is not, things still
> won't work since qemu will never send valid information for the
> GET_EVENT_STATUS_NOTIFICATION command.
>
> > >However, a hack in the kernel can be used without any QEMU changes
> > >(revalidate disk on each sr_open() call, irrespective of detecting any
> > >media change). I'm against doing that for upstream, but downstreams
> > >could do that for new guest - old hypervisor compat.
> >
> > Seriously confused. Please use the kernels "host kernel" and "qemu"
> > instead of "hypervisor" which is ambiguous.
>
> OK: this last bit says that forcefully revalidating discs in the guest
> kernel when a guest userspace opens the disc will ensure size changes
> are reflected properly for guest userspace. So in this case, even if
> we're using an older qemu which doesn't implement
> GET_EVENT_STATUS_NOTIFICATION, guest userspace apps will work fine.
>
> This is obviously a hack.
Yes. Thanks for the clarification.
(let's see if I really got it - we have a kernel bug that hit both the
guest and the host, plus a qemu bug?)
--
error compiling committee.c: too many arguments to function
From amit.shah at redhat.com Tue Apr 5 09:26:48 2011
From: amit.shah at redhat.com (Amit Shah)
Date: Tue, 5 Apr 2011 14:56:48 +0530
Subject: [libvirt] [Qemu-devel] [PATCH v2 3/3] raw-posix: Re-open host
CD-ROM after media change
In-Reply-To: <4D9ADE2A.2020201@redhat.com>
References: <4D99C61E.3080600@redhat.com> <4D99C9ED.3020602@codemonkey.ws>
<4D99CC74.9070703@redhat.com>
<20110405064120.GB2872@amit-x200.redhat.com>
<4D9AC940.5000502@redhat.com>
<20110405080900.GE2872@amit-x200.redhat.com>
<4D9ADA36.8040306@redhat.com>
<20110405091203.GC27661@amit-x200.redhat.com>
<4D9ADE2A.2020201@redhat.com>
Message-ID: <20110405092648.GA28577@amit-x200.redhat.com>
On (Tue) 05 Apr 2011 [12:17:30], Avi Kivity wrote:
> On 04/05/2011 12:12 PM, Amit Shah wrote:
> >On (Tue) 05 Apr 2011 [12:00:38], Avi Kivity wrote:
> >> On 04/05/2011 11:09 AM, Amit Shah wrote:
> >> >On (Tue) 05 Apr 2011 [10:48:16], Avi Kivity wrote:
> >> >> On 04/05/2011 09:41 AM, Amit Shah wrote:
> >> >> >See http://www.spinics.net/lists/linux-scsi/msg51504.html
> >> >>
> >> >> I see this is quite fresh. What are the plans here?
> >> >
> >> >We're still discussing where the fix should be, but it certainly is a
> >> >kernel bug and should be fixed there, and then applied to stable.
> >> >
> >> >However, there are other bugs in qemu which will prevent the right
> >> >size changes to be visible in the guest (the RFC series I sent out
> >> >earlier in this thread need to be applied to QEMU at the least, the
> >> >series has grown in my development tree since the time I sent that one
> >> >out). So essentially we need to update both, the hypervisor and the
> >> >guest to get proper CDROM media change support.
> >>
> >> Why do we need to update the guest for a qemu bug? What is the qemu bug?
> >
> >Guest kernel bug: CDROM change event missed, so the the revalidate
> >call isn't made, which causes stale data (like disc size) to be used
> >on newer media.
> >
> >qemu bug: We don't handle the GET_EVENT_STATUS_NOTIFICATION command
> >from guests (which is a mandatory command acc. to scsi spec) which the
> >guest uses to detect CDROM changes. Once this command is implemented,
> >QEMU sends the required info the guest needs to detect CDROM changes.
> >I have this implemented locally (also sent as RFC PATCH 2/3 in the
> >'cdrom bug roundup' thread.
> >
> >So: even if qemu is updated to handle this command, the guest won't
> >work correctly since it misses the event.
>
> Okay. We aren't responsible for guest kernel bugs, especially those
> which apply to real hardware (we should make more effort for virtio
> bugs). It's enough that we fix qemu here.
>
> >> >It also looks like we can't have a workaround in QEMU to get older
> >> >guests to work.
> >>
> >> Older guests? or older hosts?
> >
> >Older guests (not patched with fix for the bug described above).
> >
> >Since the guest kernel completely misses the disc change event in the
> >path that does the revalidation, there's nothing qemu can do that will
> >make such older guests notice disc change.
> >
> >Also: if only the guest kernel is updated by qemu is not, things still
> >won't work since qemu will never send valid information for the
> >GET_EVENT_STATUS_NOTIFICATION command.
> >
> >> >However, a hack in the kernel can be used without any QEMU changes
> >> >(revalidate disk on each sr_open() call, irrespective of detecting any
> >> >media change). I'm against doing that for upstream, but downstreams
> >> >could do that for new guest - old hypervisor compat.
> >>
> >> Seriously confused. Please use the kernels "host kernel" and "qemu"
> >> instead of "hypervisor" which is ambiguous.
> >
> >OK: this last bit says that forcefully revalidating discs in the guest
> >kernel when a guest userspace opens the disc will ensure size changes
> >are reflected properly for guest userspace. So in this case, even if
> >we're using an older qemu which doesn't implement
> >GET_EVENT_STATUS_NOTIFICATION, guest userspace apps will work fine.
> >
> >This is obviously a hack.
>
> Yes. Thanks for the clarification.
>
> (let's see if I really got it - we have a kernel bug that hit both
> the guest and the host, plus a qemu bug?)
Yes -- but just that we have many more qemu bugs.
Our cdrom emulation has a lot of holes when it comes to being
spec-compliant. I have a few fixes, Markus is working on some as well.
Amit
From mcastrol at gmail.com Tue Apr 5 09:57:02 2011
From: mcastrol at gmail.com (=?ISO-8859-1?Q?Marcela_Castro_Le=F3n?=)
Date: Tue, 5 Apr 2011 11:57:02 +0200
Subject: [libvirt] Using Restore in another host.
In-Reply-To: <20110404102013.GB13616@redhat.com>
References:
<20110404102013.GB13616@redhat.com>
Message-ID:
Hello Daniel
Thank you for all your information, but I still didn't solve the problem. I
tried the option you mention, with two differents guest into two differents
host, but all the cases I've got:
*virsh # restore sv-chubut-2011-04-04-17:38*
*error: Failed to restore domain from sv-chubut-2011-04-04-17:38*
*error: monitor socket did not show up.: Connection refused***
I cannot get any useful information (at least form me) on the log you
mention.
I'd appreciate a lot a new suggestion.
Thanks
Marcela
2011/4/4 Daniel P. Berrange
> On Sun, Apr 03, 2011 at 10:43:45AM +0200, Marcela Castro Le?n wrote:
> > Hello:
> > I need to know if I can use the restore operation (virsh o the equivalent
> in
> > libvirt) to recover a previous state of a guest, but recovered previously
> in
> > another host.
> > I did a test, but I got an error:
> >
> > The exactly sequence using virsh I testes is:
> > On [HOST SOURCE]: Using virsh
> > 1) save [domain] [file]
> > 2) restore file
> > 3) destroy [domain]
> >
> > On [HOST SOURCE] using ubuntu sh
> > 4) cp [guest.img] [guest.xml] [file] to HOST2
> >
> > On [HOST TARGET] using virsh
> > 5) define [guest.xml] (using image on destination in HOST2)
> > 6) restore [file]
>
> As a general rule you should only ever 'restore' from a
> file *once*. This is because after the first restore
> operation, the guest may have made writes to its disk.
> Restoring a second time the guest OS will likely have
> an inconsistent view of the disk & will cause filesystem
> corruption.
>
> If you want to be able to restore from a saved image
> multiple times, you need to also take a snapshot of
> the disk image at the same time, and restore that
> snapshot when restoring the memory image.
>
>
> That aside, saving on one host & restoring on a
> different host is fine. So if you leave out steps
> 2+3 in your example above, then your data would
> still be safe.
>
> > The restore troughs the following message:
> > *virsh # restore sv-chubut-2011-04-01-09:58
> > error: Failed to restore domain from sv-chubut-2011-04-01-09:58
> > error: monitor socket did not show up.: Connection refused*
>
> There is probably some configuration difference on your 2nd host
> that prevented the VM from starting up. If you're lucky the file
> /var/log/libvirt/qemu/$NAME.log will tell you more
>
> Daniel
> --
> |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/:|
> |: http://libvirt.org -o- http://virt-manager.org:|
> |: http://autobuild.org -o- http://search.cpan.org/~danberr/:|
> |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc:|
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From berrange at redhat.com Tue Apr 5 10:36:36 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Tue, 5 Apr 2011 11:36:36 +0100
Subject: [libvirt] [PATCH 6/6] Remove unused macros and enable
-Wunused-macros
In-Reply-To: <4D9A3004.50305@redhat.com>
References: <1301934004-6204-1-git-send-email-berrange@redhat.com>
<1301934004-6204-7-git-send-email-berrange@redhat.com>
<4D9A3004.50305@redhat.com>
Message-ID: <20110405103636.GB32225@redhat.com>
On Mon, Apr 04, 2011 at 02:54:28PM -0600, Eric Blake wrote:
> On 04/04/2011 10:20 AM, Daniel P. Berrange wrote:
> > * m4/virt-compile-warnings.m4: Enable -Wunused-macros
> > * daemon/libvirtd.c: Remove MAX_LISTEN
> > * daemon/remote.c: Remote VIR_FROM_THIS
>
> s/Remote/Remove/
>
> > 33 files changed, 38 insertions(+), 108 deletions(-)
>
> Nice ratio!
>
> > +++ b/src/esx/esx_vi_methods.c
> > @@ -1,4 +1,3 @@
> > -
> > /*
> > * esx_vi_methods.c: client for the VMware VI API 2.5 to manage ESX hosts
> > *
> > @@ -52,8 +51,10 @@
> >
> >
> >
> > +#if 0
> > #define ESX_VI__METHOD__CHECK_OUTPUT__RequiredList \
>
> Won't this cause 'make syntax-check' grief during cppi checks? (Multiple
> instances)
>
> > +++ b/tools/virsh.c
> > @@ -409,15 +409,6 @@ _vshStrdup(vshControl *ctl, const char *s, const char *filename, int line)
> > exit(EXIT_FAILURE);
> > }
> >
> > -/* Poison the raw allocating identifiers in favor of our vsh variants. */
> > -#undef malloc
> > -#undef calloc
> > -#undef realloc
> > -#undef strdup
> > -#define malloc use_vshMalloc_instead_of_malloc
> > -#define calloc use_vshCalloc_instead_of_calloc
> > -#define realloc use_vshRealloc_instead_of_realloc
> > -#define strdup use_vshStrdup_instead_of_strdup
>
> Hmm, I don't want to completely lose this. Can we instead include
> "warn-on-use.h" (already provided by gnulib) and do:
>
> _GL_WARN_ON_USE(malloc, "use vshMalloc instead of malloc");
>
> to get the same poisoning effects but via magic attributes rather than
> unused macros?
That doesn't work either:
cc1: warnings being treated as errors
virsh.c:366:1: error: redundant redeclaration of 'malloc' [-Wredundant-decls]
virsh.c:367:1: error: redundant redeclaration of 'calloc' [-Wredundant-decls]
virsh.c:368:1: error: redundant redeclaration of 'realloc' [-Wredundant-decls]
virsh.c:369:1: error: redundant redeclaration of 'strdup' [-Wredundant-decls]
What we really want is a syntax-check rule for these i reckon
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From berrange at redhat.com Tue Apr 5 10:41:36 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Tue, 5 Apr 2011 11:41:36 +0100
Subject: [libvirt] [PATCH 1/6] Use gnulib's manywarnings & warnings
modules
In-Reply-To: <4D9A2A12.3010401@redhat.com>
References: <1301934004-6204-1-git-send-email-berrange@redhat.com>
<1301934004-6204-2-git-send-email-berrange@redhat.com>
<4D9A2A12.3010401@redhat.com>
Message-ID: <20110405104136.GC32225@redhat.com>
On Mon, Apr 04, 2011 at 02:29:06PM -0600, Eric Blake wrote:
> On 04/04/2011 10:19 AM, Daniel P. Berrange wrote:
> > Remove custom code for checking compiler warnings, using
> > gl_WARN_ADD instead. Don't list all flags ourselves, use
> > gnulib's gl_MANYWARN_ALL_GCC to get all possible GCC flags,
> > then turn off the ones we don't want yet.
> >
> > * acinclude.m4: Rewrite to use gl_WARN_ADD and gl_MANYWARN_ALL_GCC
> > * bootstrap.conf: Add warnings & manywarnings
> > * configure.ac: Switch to gl_WARN_ADD
> > * m4/compiler-flags.m4: Obsoleted by gl_WARN_ADD
> > ---
> > acinclude.m4 | 158 +++++++++++++++++++++++++++-----------------------
> > bootstrap.conf | 2 +
> > configure.ac | 15 +++--
> > m4/compiler-flags.m4 | 48 ---------------
> > 4 files changed, 96 insertions(+), 127 deletions(-)
> > delete mode 100644 m4/compiler-flags.m4
>
> > +
> > + # List of warnings that are not relevant / wanted
> > + dontwarn="$dontwarn -Wc++-compat" # Don't care about C++ compiler compat
> > + dontwarn="$dontwarn -Wtraditional" # Don't care about ancient C standard compat
> > + dontwarn="$dontwarn -Wtraditional-conversion" # Don't care about ancient C standard compat
> > + dontwarn="$dontwarn -Wsystem-headers" # Ignore warnings in /usr/include
> > + dontwarn="$dontwarn -Wpadded" # Happy for compiler to add struct padding
> > + dontwarn="$dontwarn -Wunreachable-code" # GCC very confused with -O2
> > + dontwarn="$dontwarn -Wconversion" # Too many to deal with
> > + dontwarn="$dontwarn -Wsign-conversion" # Too many to deal with
> > + dontwarn="$dontwarn -Wvla" # GNULIB gettext.h violates
> > + dontwarn="$dontwarn -Wundef" # Many GNULIB violations
> > + dontwarn="$dontwarn -Wcast-qual" # Need to allow bad cast for execve()
> > + dontwarn="$dontwarn -Wlong-long" # We need to use long long in many places
> > + dontwarn="$dontwarn -Wswitch-default" # We allow manual list of all enum cases without default:
> > + dontwarn="$dontwarn -Wswitch-enum" # We allow optional default: instead of listing all enum values
> > + dontwarn="$dontwarn -Wstrict-overflow" # Not a problem since we don't use -fstrict-overflow
> > + dontwarn="$dontwarn -Wunsafe-loop-optimizations" # Not a problem since we don't use -funsafe-loop-optimizations
>
> Seems okay (but long lines - any way to break that into 80 columns?)
>
> > +
> > + # We might fundamentally need some of these disabled forever, but ideally
> > + # we'd turn many of them on
> > + dontwarn="$dontwarn -Wformat-nonliteral"
>
> This one may need to always be disabled, thanks to virAsprintf (it would
> be nicer if we could disable for just one or two files, rather than
> globally).
>
> > + dontwarn="$dontwarn -Wfloat-equal"
> > + dontwarn="$dontwarn -Wdeclaration-after-statement"
>
> If gcc would do better, I'd love to guarantee C99 and take advantage of
> this (smaller scopes have maintenance benefits) - thus, I envision this
> one being permanent (float it up to the earlier set).
>
> > + dontwarn="$dontwarn -Wcast-qual"
> > + dontwarn="$dontwarn -Wconversion"
> > + dontwarn="$dontwarn -Wsign-conversion"
> > + dontwarn="$dontwarn -Wold-style-definition"
> > + dontwarn="$dontwarn -Wmissing-noreturn"
> > + dontwarn="$dontwarn -Wpacked"
> > + dontwarn="$dontwarn -Wunused-macros"
> > + dontwarn="$dontwarn -Woverlength-strings"
> > + dontwarn="$dontwarn -Wmissing-format-attribute"
> > + dontwarn="$dontwarn -Wstack-protector"
>
> Yes, I agree that the rest of these should be temporary, and are
> probably worth fixing.
>
> > +
> > + # Get all possible GCC warnings
> > + gl_MANYWARN_ALL_GCC([maybewarn])
> > +
> > + # Remove the ones we don't want, blacklisted earlier
> > + gl_MANYWARN_COMPLEMENT([wantwarn], [$maybewarn], [$dontwarn])
> > +
> > + # Check for $CC support of each warning
> > + for w in $wantwarn; do
> > + gl_WARN_ADD([$w])
> > + done
> > +
> > + # GNULIB uses '-W' which includes a bunch of stuff,
> > + # kinda like -Wextra. Unfortunately, it means you
>
> "kinda like"? Exactly like! -W was the old spelling, -Wextra was the
> new one (added quite some time ago; something like gcc 3.4, off the top
> of my head).
Ah, I didn't realize it was the same.
>
> > + # can't simply use '-Wsign-compare' with gl_MANYWARN_COMPLEMENT
> > + # So we have -W enabled, and then have to explicitly turn off
> > + gl_WARN_ADD(-Wno-sign-compare)
> > +
> > + # This should be < 256 really, but with PATH_MAX everywhere
> > + # we have doom, even with 4096. In fact we have some functions
> > + # with several PATH_MAX sized variables :-( We should kill off
> > + # all PATH_MAX usage and then lower this limit
> > + gl_WARN_ADD([-Wframe-larger-than=65700])
> > + dnl gl_WARN_ADD([-Wframe-larger-than=4096])
> > + dnl gl_WARN_ADD([-Wframe-larger-than=256])
> > +
> > + # Extra special flags
> > + gl_WARN_ADD([-Wp,-D_FORTIFY_SOURCE=2])
> > + dnl Fedora only uses -fstack-protector, but doesn't seem to
> > + dnl be great overhead in adding -fstack-protector-all instead
> > + dnl gl_WARN_ADD([-fstack-protector])
> > + gl_WARN_ADD([-fstack-protector-all])
> > + gl_WARN_ADD([--param=ssp-buffer-size=4])
> > + gl_WARN_ADD([-fexceptions])
> > + gl_WARN_ADD([-fasynchronous-unwind-tables])
> > + gl_WARN_ADD([-fdiagnostics-show-option])
> > +
> > + if test "$enable_compile_warnings" = "error"
> > + then
> > + gl_WARN_ADD([-Werror])
> > + fi
>
> Looks like a good conversion.
I also added
gl_WARN_ADD([-Wjump-misses-init])
because we loose that due to turning off -Wc++-compat
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From berrange at redhat.com Tue Apr 5 10:42:46 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Tue, 5 Apr 2011 11:42:46 +0100
Subject: [libvirt] [PATCH 2/6] Remove acinclude.m4 file
In-Reply-To: <4D9A2BEC.1080809@redhat.com>
References: <1301934004-6204-1-git-send-email-berrange@redhat.com>
<1301934004-6204-3-git-send-email-berrange@redhat.com>
<4D9A2BEC.1080809@redhat.com>
Message-ID: <20110405104246.GD32225@redhat.com>
On Mon, Apr 04, 2011 at 02:37:00PM -0600, Eric Blake wrote:
> On 04/04/2011 10:20 AM, Daniel P. Berrange wrote:
> > Split the bit acinclude.m4 file into smaller pieces named
> > as m4/virt-XXXXX.m4
> >
> > * .gitignore: Ignore gettext related files
> > * acinclude.m4: Delete
> > * m4/virt-compile-warnings.m4: Checks for GCC compiler flags
> > * m4/virt-pkgconfig-back-compat.m4: Backcompat check for
> > pkgconfig program
> > ---
> > .gitignore | 36 +++++++++-
> > acinclude.m4 | 137 --------------------------------------
> > m4/virt-compile-warnings.m4 | 112 +++++++++++++++++++++++++++++++
> > m4/virt-pkgconfig-back-compat.m4 | 23 ++++++
> > 4 files changed, 169 insertions(+), 139 deletions(-)
> > delete mode 100644 acinclude.m4
> > create mode 100644 m4/virt-compile-warnings.m4
> > create mode 100644 m4/virt-pkgconfig-back-compat.m4
> >
> > diff --git a/.gitignore b/.gitignore
> > index ba4d351..278bc4f 100644
> > --- a/.gitignore
> > +++ b/.gitignore
> > @@ -1,4 +1,3 @@
> > -!/m4/compiler-flags.m4
> > !/po/*.po
> > !/po/POTFILES.in
> > !/po/libvirt.pot
> > @@ -46,7 +45,6 @@
> > /libvirt.spec
>
> Yuck - gnulib's bootstrap script sorts .gitignore, but this is broken
> (lines starting with ! should come last, not first, according to 'man
> gitignore'; it's a shame I'm just noticing it now, since it's been
> broken since November 2010).
>
> > @@ -67,3 +65,37 @@ results.log
> > stamp-h
> > stamp-h.in
> > stamp-h1
> > +m4/codeset.m4
> > +m4/gettext.m4
>
> Rerunning bootstrap will re-sort this list, leading to spurious diffs
> unless we get it sorted first. But why should we blacklist all of the
> m4 files individually, when it is much easier to whitelist just the
> files we want?
>
> /m4/
> !/m4/virt-*.m4
Ok, I've pushed with that, but with the bogus sort order, since
it is no worse than what we already have. We can fix sort order
once gnulib is fixed.
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From berrange at redhat.com Tue Apr 5 10:43:48 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Tue, 5 Apr 2011 11:43:48 +0100
Subject: [libvirt] [PATCH 4/6] Enable use of -Wmissing-noreturn
In-Reply-To: <4D9A2D2A.3060108@redhat.com>
References: <1301934004-6204-1-git-send-email-berrange@redhat.com>
<1301934004-6204-5-git-send-email-berrange@redhat.com>
<4D9A2D2A.3060108@redhat.com>
Message-ID: <20110405104348.GE32225@redhat.com>
On Mon, Apr 04, 2011 at 02:42:18PM -0600, Eric Blake wrote:
> On 04/04/2011 10:20 AM, Daniel P. Berrange wrote:
> > * src/internal.h: Define a ATTRIBUTE_NO_RETURN annotation
> > * src/lxc/lxc_container.c: Annotate lxcContainerDummyChild
> > with ATTRIBUTE_NO_RETURN
> > * tests/eventtest.c: Mark async thread as ATTRIBUTE_NO_RETURN
> > * m4/virt-compile-warnings.m4: Enable -Wmissing-noreturn
> > ---
> > m4/virt-compile-warnings.m4 | 1 -
> > src/internal.h | 9 +++++++++
> > src/lxc/lxc_container.c | 3 ++-
> > tests/eventtest.c | 3 +--
> > 4 files changed, 12 insertions(+), 4 deletions(-)
>
> >
> > +++ b/src/internal.h
> > @@ -117,6 +117,15 @@
> > # endif
> >
> > /**
> > + * ATTRIBUTE_NORETURN:
> > + *
> > + * Macro to indicate that a function won't return to the caller
> > + */
> > +# ifndef ATTRIBUTE_NORETURN
> > +# define ATTRIBUTE_NORETURN __attribute__((__noreturn__))
> > +# endif
>
> Do we need a minimum gcc version detection, so this cause grief on older
> setups?
It has existed since gcc 2.4, so IMHO that is so old we don't need
the check
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
From berrange at redhat.com Tue Apr 5 11:10:54 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Tue, 5 Apr 2011 12:10:54 +0100
Subject: [libvirt] [PATCH v3] Improve SCSI volume key generation
Message-ID: <1302001854-2218-1-git-send-email-berrange@redhat.com>
The SCSI volumes get a better 'key' field based on the fully
qualified volume path. All SCSI volumes have a unique serial
available in hardware which can be obtained by sending a
suitable SCSI command. Call out to udev's 'scsi_id' command
to fetch this value
In v3:
- Use virCommandSetOutputBuffer/virCommandRun instead
of VIR_FDOPEN
- Skip serial if it matches empty string
* src/storage/storage_backend_scsi.c: Improve volume key
field value stability and uniqueness
---
src/storage/storage_backend_scsi.c | 45 ++++++++++++++++++++++++++++++++---
1 files changed, 41 insertions(+), 4 deletions(-)
diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c
index d880d65..da34547 100644
--- a/src/storage/storage_backend_scsi.c
+++ b/src/storage/storage_backend_scsi.c
@@ -33,6 +33,7 @@
#include "memory.h"
#include "logging.h"
#include "files.h"
+#include "command.h"
#define VIR_FROM_THIS VIR_FROM_STORAGE
@@ -160,6 +161,45 @@ cleanup:
return ret;
}
+
+static char *
+virStorageBackendSCSISerial(const char *dev)
+{
+ char *serial = NULL;
+#ifdef HAVE_UDEV
+ virCommandPtr cmd = virCommandNewArgList(
+ "/lib/udev/scsi_id",
+ "--replace-whitespace",
+ "--whitelisted",
+ "--device", dev,
+ NULL
+ );
+
+ /* Run the program and capture its output */
+ virCommandSetOutputBuffer(cmd, &serial);
+ if (virCommandRun(cmd, NULL) < 0)
+ goto cleanup;
+#endif
+
+ if (serial && STRNEQ(serial, "")) {
+ char *nl = strchr(serial, '\n');
+ if (nl)
+ *nl = '\0';
+ } else {
+ VIR_FREE(serial);
+ if (!(serial = strdup(dev)))
+ virReportOOMError();
+ }
+
+#ifdef HAVE_UDEV
+cleanup:
+ virCommandFree(cmd);
+#endif
+
+ return serial;
+}
+
+
static int
virStorageBackendSCSINewLun(virStoragePoolObjPtr pool,
uint32_t host ATTRIBUTE_UNUSED,
@@ -233,10 +273,7 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool,
goto free_vol;
}
- /* XXX should use logical unit's UUID instead */
- vol->key = strdup(vol->target.path);
- if (vol->key == NULL) {
- virReportOOMError();
+ if (!(vol->key = virStorageBackendSCSISerial(vol->target.path))) {
retval = -1;
goto free_vol;
}
--
1.7.4
From minovotn at redhat.com Tue Apr 5 11:38:12 2011
From: minovotn at redhat.com (Michal Novotny)
Date: Tue, 05 Apr 2011 13:38:12 +0200
Subject: [libvirt] Using Restore in another host.
In-Reply-To:
References: <20110404102013.GB13616@redhat.com>
Message-ID: <4D9AFF24.6060109@redhat.com>
Hi Marcela,
is any other guest on the host that cannot restore this VM working fine ?
You could also try running the:
*/# LIBVIRT_DEBUG=1 virsh restore sv-chubut-2011-04-04-17:38 2>
virsh-restore.log
/*command which would enable the libvirt logging and output the debug
log into the virsh-restore.log file. This file could be sent to the list
for analysis what's wrong.
Thanks,
Michal
On 04/05/2011 11:57 AM, Marcela Castro Le?n wrote:
> Hello Daniel
> Thank you for all your information, but I still didn't solve the
> problem. I tried the option you mention, with two differents guest
> into two differents host, but all the cases I've got:
>
> */virsh # restore sv-chubut-2011-04-04-17:38/*
> */error: Failed to restore domain from sv-chubut-2011-04-04-17:38/*
> */error: monitor socket did not show up.: Connection refused/*
>
> I cannot get any useful information (at least form me) on the log you
> mention.
> I'd appreciate a lot a new suggestion.
> Thanks
> Marcela
>
>
>
>
> 2011/4/4 Daniel P. Berrange >
>
> On Sun, Apr 03, 2011 at 10:43:45AM +0200, Marcela Castro Le?n wrote:
> > Hello:
> > I need to know if I can use the restore operation (virsh o the
> equivalent in
> > libvirt) to recover a previous state of a guest, but recovered
> previously in
> > another host.
> > I did a test, but I got an error:
> >
> > The exactly sequence using virsh I testes is:
> > On [HOST SOURCE]: Using virsh
> > 1) save [domain] [file]
> > 2) restore file
> > 3) destroy [domain]
> >
> > On [HOST SOURCE] using ubuntu sh
> > 4) cp [guest.img] [guest.xml] [file] to HOST2
> >
> > On [HOST TARGET] using virsh
> > 5) define [guest.xml] (using image on destination in HOST2)
> > 6) restore [file]
>
> As a general rule you should only ever 'restore' from a
> file *once*. This is because after the first restore
> operation, the guest may have made writes to its disk.
> Restoring a second time the guest OS will likely have
> an inconsistent view of the disk & will cause filesystem
> corruption.
>
> If you want to be able to restore from a saved image
> multiple times, you need to also take a snapshot of
> the disk image at the same time, and restore that
> snapshot when restoring the memory image.
>
>
> That aside, saving on one host & restoring on a
> different host is fine. So if you leave out steps
> 2+3 in your example above, then your data would
> still be safe.
>
> > The restore troughs the following message:
> > *virsh # restore sv-chubut-2011-04-01-09:58
> > error: Failed to restore domain from sv-chubut-2011-04-01-09:58
> > error: monitor socket did not show up.: Connection refused*
>
> There is probably some configuration difference on your 2nd host
> that prevented the VM from starting up. If you're lucky the file
> /var/log/libvirt/qemu/$NAME.log will tell you more
>
> Daniel
> --
> |: http://berrange.com -o-
> http://www.flickr.com/photos/dberrange/ :|
> |: http://libvirt.org -o-
> http://virt-manager.org :|
> |: http://autobuild.org -o-
> http://search.cpan.org/~danberr/
> :|
> |: http://entangle-photo.org -o-
> http://live.gnome.org/gtk-vnc :|
>
>
>
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
--
Michal Novotny , RHCE
Virtualization Team (xen userspace), Red Hat
From jyang at redhat.com Tue Apr 5 12:38:47 2011
From: jyang at redhat.com (Osier Yang)
Date: Tue, 5 Apr 2011 20:38:47 +0800
Subject: [libvirt] [PATCH] virsh: Fix a problem of argv parsing
Message-ID: <1302007127-16185-1-git-send-email-jyang@redhat.com>
Problem example:
# virsh -d 5 vol-create --pool default col.xml
vol-create: pool(optdata): default
vol-create: pool(optdata): col.xml
error: command 'vol-create' requires option
It gets same "vshCmdOptDef" for both "--pool default"
and "col.xml".
This patch fixes it by increase "data_ct" when things like
"--pool default" is successfully parsed, so that could
get right "vshCmdOptDef" for the other arguments which
are not with option name together.
---
tools/virsh.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 19e3449..4d52bfb 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -11750,6 +11750,8 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser)
VSH_OT_INT ? _("number") : _("string"));
goto syntaxError;
}
+
+ data_ct++;
} else {
tkdata = NULL;
if (optstr) {
--
1.7.4
From stefanha at gmail.com Tue Apr 5 05:33:36 2011
From: stefanha at gmail.com (Stefan Hajnoczi)
Date: Tue, 5 Apr 2011 06:33:36 +0100
Subject: [libvirt] [Qemu-devel] [PATCH v2 3/3] raw-posix: Re-open host
CD-ROM after media change
In-Reply-To: <4D9A05D1.1000501@gmail.com>
References: <1301425482-8722-1-git-send-email-stefanha@linux.vnet.ibm.com>
<1301425482-8722-4-git-send-email-stefanha@linux.vnet.ibm.com>
<4D99C61E.3080600@redhat.com> <4D99C9ED.3020602@codemonkey.ws>
<4D9A05D1.1000501@gmail.com>
Message-ID:
On Mon, Apr 4, 2011 at 6:54 PM, David Ahern wrote:
>
>
> On 04/04/11 07:38, Anthony Liguori wrote:
>> On 04/04/2011 08:22 AM, Avi Kivity wrote:
>>> On 04/03/2011 02:57 PM, Stefan Hajnoczi wrote:
>>>> In order for media change to work with Linux host CD-ROM it is
>>>> necessary to reopen the file (otherwise the inode size will not
>>>> refresh, this is an issue with existing kernels).
>>>>
>>>
>>> Maybe we should fix the bug in Linux (and backport as necessary)?
>>>
>>> I think cd-rom assignment is sufficiently obscure that we can require
>>> a fixed kernel instead of providing a workaround.
>>
>> Do reads fail after CD change? ?Or do they succeed and the size is just
>> reported incorrectly?
>>
>> If it's the later, I'd agree that it needs fixing in the kernel. ?If
>> it's the former, I'd say it's clearly a feature.
>
> In January 2010 I was seeing old data -- data from the prior CD -- in
> the guest after the media change.
Yikes. Is there a bug report for this? What are the steps to reproduce it?
Stefan
From dsahern at gmail.com Tue Apr 5 05:42:57 2011
From: dsahern at gmail.com (David Ahern)
Date: Mon, 04 Apr 2011 23:42:57 -0600
Subject: [libvirt] [Qemu-devel] [PATCH v2 3/3] raw-posix: Re-open host
CD-ROM after media change
In-Reply-To:
References: <1301425482-8722-1-git-send-email-stefanha@linux.vnet.ibm.com> <1301425482-8722-4-git-send-email-stefanha@linux.vnet.ibm.com> <4D99C61E.3080600@redhat.com> <4D99C9ED.3020602@codemonkey.ws> <4D9A05D1.1000501@gmail.com>
Message-ID: <4D9AABE1.9030609@gmail.com>
On 04/04/11 23:33, Stefan Hajnoczi wrote:
> On Mon, Apr 4, 2011 at 6:54 PM, David Ahern wrote:
>> On 04/04/11 07:38, Anthony Liguori wrote:
>>> On 04/04/2011 08:22 AM, Avi Kivity wrote:
>>>> On 04/03/2011 02:57 PM, Stefan Hajnoczi wrote:
>>>>> In order for media change to work with Linux host CD-ROM it is
>>>>> necessary to reopen the file (otherwise the inode size will not
>>>>> refresh, this is an issue with existing kernels).
>>>>>
>>>>
>>>> Maybe we should fix the bug in Linux (and backport as necessary)?
>>>>
>>>> I think cd-rom assignment is sufficiently obscure that we can require
>>>> a fixed kernel instead of providing a workaround.
>>>
>>> Do reads fail after CD change? Or do they succeed and the size is just
>>> reported incorrectly?
>>>
>>> If it's the later, I'd agree that it needs fixing in the kernel. If
>>> it's the former, I'd say it's clearly a feature.
>>
>> In January 2010 I was seeing old data -- data from the prior CD -- in
>> the guest after the media change.
>
> Yikes. Is there a bug report for this? What are the steps to reproduce it?
Not that I know of. It is reported by someone else last year as well:
http://www.mail-archive.com/kvm at vger.kernel.org/msg32999.html
>
> Stefan
From jdenemar at redhat.com Tue Apr 5 13:00:06 2011
From: jdenemar at redhat.com (Jiri Denemark)
Date: Tue, 5 Apr 2011 15:00:06 +0200
Subject: [libvirt] [PATCH] qemu: Rewrite LOOKUP_PTYS macro into a
function
In-Reply-To: <4D9A20B0.6070405@redhat.com>
References: <6583e184fb3f616c15ec4bc42f1af58fff320a8b.1301924390.git.jdenemar@redhat.com>
<4D9A20B0.6070405@redhat.com>
Message-ID: <20110405130006.GA7195@orkuz.home>
On Mon, Apr 04, 2011 at 13:49:04 -0600, Eric Blake wrote:
> On 04/04/2011 07:46 AM, Jiri Denemark wrote:
> > The macro is huge and gives us nothing but headache when maintaining it.
> > ---
> > The reason for this patch is not that I'm going to modify anything in
> > the code. It's that I was working in the area and noticed this huge
> > macro.
> >
> > src/qemu/qemu_process.c | 102 ++++++++++++++++++++++++++++-------------------
> > 1 files changed, 61 insertions(+), 41 deletions(-)
>
> The diffstat hides the fact that this really is a code cleanup.
>
> ACK.
Thanks, pushed.
Jirka
From jdenemar at redhat.com Tue Apr 5 13:00:24 2011
From: jdenemar at redhat.com (Jiri Denemark)
Date: Tue, 5 Apr 2011 15:00:24 +0200
Subject: [libvirt] [PATCH] qemu: Ignore unusable binaries
In-Reply-To: <4D9A44DB.1080802@redhat.com>
References:
<4D9A44DB.1080802@redhat.com>
Message-ID: <20110405130024.GB7195@orkuz.home>
On Mon, Apr 04, 2011 at 16:23:23 -0600, Eric Blake wrote:
> On 04/04/2011 04:08 PM, Jiri Denemark wrote:
> > When initializing qemu guest capabilities, we should ignore qemu
> > binaries that we are not able to extract version/help info from since
> > they will be unusable for creating domains anyway. Ignoring them is also
> > much better than letting initialization of qemu driver fail.
> > ---
> > src/qemu/qemu_capabilities.c | 11 ++++++++---
> > 1 files changed, 8 insertions(+), 3 deletions(-)
>
> ACK.
Thanks, pushed.
Jirka
From jdenemar at redhat.com Tue Apr 5 13:20:38 2011
From: jdenemar at redhat.com (Jiri Denemark)
Date: Tue, 5 Apr 2011 15:20:38 +0200
Subject: [libvirt] [PATCH] qemu: Do not unlink managedsave image if
restoring fails.
In-Reply-To: <1301986042-13725-1-git-send-email-jyang@redhat.com>
References: <1301986042-13725-1-git-send-email-jyang@redhat.com>
Message-ID: <20110405132037.GC7195@orkuz.home>
On Tue, Apr 05, 2011 at 14:47:22 +0800, Osier Yang wrote:
> Both "qemuDomainStartWithFlags" and "qemuAutostartDomain" try to
> restore the domain from managedsave'ed image if it exists (by
> invoking "qemuDomainObjRestore"), but it unlinks the image even
> if restoring fails, which causes data loss.
>
> However, I'm not sure if it's the very correct way to fix it,
> if restoring fails, and we didn't remove the image, it will
> trys to restore from the image again next time, if that's
> not the user expected (e.g. the user made quite many changes
> on the guest), then it's a new problem.
I think this patch is risky. You should either remove the state on error
(which is the current state) or fail domain start if managed state is present
but resuming from it fails. If you do something in the middle (your patch) you
will certainly end up corrupting domain's disks.
Jirka
From jyang at redhat.com Tue Apr 5 13:24:39 2011
From: jyang at redhat.com (Osier Yang)
Date: Tue, 05 Apr 2011 21:24:39 +0800
Subject: [libvirt] [PATCH] qemu: Do not unlink managedsave image if
restoring fails.
In-Reply-To: <20110405132037.GC7195@orkuz.home>
References: <1301986042-13725-1-git-send-email-jyang@redhat.com>
<20110405132037.GC7195@orkuz.home>
Message-ID: <4D9B1817.50705@redhat.com>
? 2011?04?05? 21:20, Jiri Denemark ??:
> On Tue, Apr 05, 2011 at 14:47:22 +0800, Osier Yang wrote:
>> Both "qemuDomainStartWithFlags" and "qemuAutostartDomain" try to
>> restore the domain from managedsave'ed image if it exists (by
>> invoking "qemuDomainObjRestore"), but it unlinks the image even
>> if restoring fails, which causes data loss.
>>
>> However, I'm not sure if it's the very correct way to fix it,
>> if restoring fails, and we didn't remove the image, it will
>> trys to restore from the image again next time, if that's
>> not the user expected (e.g. the user made quite many changes
>> on the guest), then it's a new problem.
>
> I think this patch is risky. You should either remove the state on error
> (which is the current state) or fail domain start if managed state is present
> but resuming from it fails. If you do something in the middle (your patch) you
> will certainly end up corrupting domain's disks.
>
> Jirka
Hum, it makes sense, that's what I was worried about, I think
failing domain start will be better than data loss anyway, so
will update with that.
Thanks for the reviewing
Regards
Osier
From jyang at redhat.com Tue Apr 5 13:35:30 2011
From: jyang at redhat.com (Osier Yang)
Date: Tue, 5 Apr 2011 21:35:30 +0800
Subject: [libvirt] [PATCH v2] qemu: Do not unlink managedsave image if
restoring fails
In-Reply-To: <20110405132037.GC7195@orkuz.home>
References: <20110405132037.GC7195@orkuz.home>
Message-ID: <1302010530-23152-1-git-send-email-jyang@redhat.com>
Both "qemuDomainStartWithFlags" and "qemuAutostartDomain" try to
restore the domain from managedsave'ed image if it exists (by
invoking "qemuDomainObjRestore"), but it unlinks the image even
if restoring fails, which causes data loss.
The fix is to fail the domain startup if the restoring fails,
but doesn't unlink()s the save state.
v1 - v2:
* Fails the domain startup and throws error instead of throwing
a warning.
---
src/qemu/qemu_driver.c | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 48fe266..ef4d277 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3423,18 +3423,21 @@ static int qemudDomainObjStart(virConnectPtr conn,
/*
* If there is a managed saved state restore it instead of starting
- * from scratch. In any case the old state is removed.
+ * from scratch.
*/
managed_save = qemuDomainManagedSavePath(driver, vm);
if ((managed_save) && (virFileExists(managed_save))) {
ret = qemuDomainObjRestore(conn, driver, vm, managed_save);
- if (unlink(managed_save) < 0) {
- VIR_WARN("Failed to remove the managed state %s", managed_save);
+ if (ret == 0) {
+ if (unlink(managed_save) < 0)
+ VIR_WARN("Failed to remove the managed state %s", managed_save);
+ } else {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to restore from the managed state %s"),
+ managed_save);
}
-
- if (ret == 0)
- goto cleanup;
+ goto cleanup;
}
ret = qemuProcessStart(conn, driver, vm, NULL, start_paused, -1, NULL,
--
1.7.4
From jyang at redhat.com Tue Apr 5 13:49:58 2011
From: jyang at redhat.com (Osier Yang)
Date: Tue, 5 Apr 2011 21:49:58 +0800
Subject: [libvirt] [PATCH] qemu: Always reserves slot 0x02 for primary VGA.
Message-ID: <1302011398-25541-1-git-send-email-jyang@redhat.com>
To address https://bugzilla.redhat.com/show_bug.cgi?id=692355
This fix is to reserve slot 0x02 for primary VGA even if there
is no "video" specified in domain XML to avoid the problem.
---
src/qemu/qemu_command.c | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 3d25ba4..9b93d5e 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -947,6 +947,7 @@ qemuAssignDevicePCISlots(virDomainDefPtr def, qemuDomainPCIAddressSetPtr addrs)
{
int i;
bool reservedIDE = false;
+ bool reservedVGA = false;
/* Host bridge */
if (qemuDomainPCIAddressReserveSlot(addrs, 0) < 0)
@@ -966,7 +967,7 @@ qemuAssignDevicePCISlots(virDomainDefPtr def, qemuDomainPCIAddressSetPtr addrs)
_("Primary IDE controller must have PCI address 0:0:1.1"));
goto error;
}
- /* If TYPE==PCI, then then qemuCollectPCIAddress() function
+ /* If TYPE==PCI, then qemuCollectPCIAddress() function
* has already reserved the address, so we must skip */
reservedIDE = true;
} else {
@@ -997,16 +998,22 @@ qemuAssignDevicePCISlots(virDomainDefPtr def, qemuDomainPCIAddressSetPtr addrs)
_("Primary video card must have PCI address 0:0:2.0"));
goto error;
}
+ /* If TYPE==PCI, then qemuCollectPCIAddress() function
+ * has already reserved the address, so we must skip */
+ reservedVGA = true;
} else {
def->videos[0]->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
def->videos[0]->info.addr.pci.domain = 0;
def->videos[0]->info.addr.pci.bus = 0;
def->videos[0]->info.addr.pci.slot = 2;
def->videos[0]->info.addr.pci.function = 0;
- if (qemuDomainPCIAddressReserveSlot(addrs, 2) < 0)
- goto error;
}
}
+
+ if (!reservedVGA
+ && qemuDomainPCIAddressReserveSlot(addrs, 2) < 0)
+ goto error;
+
for (i = 0; i < def->nfss ; i++) {
if (def->fss[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
continue;
--
1.7.4
From stefanha at gmail.com Tue Apr 5 12:41:37 2011
From: stefanha at gmail.com (Stefan Hajnoczi)
Date: Tue, 5 Apr 2011 13:41:37 +0100
Subject: [libvirt] [Qemu-devel] [PATCH v2 3/3] raw-posix: Re-open host
CD-ROM after media change
In-Reply-To: <4D9AABE1.9030609@gmail.com>
References: <1301425482-8722-1-git-send-email-stefanha@linux.vnet.ibm.com>
<1301425482-8722-4-git-send-email-stefanha@linux.vnet.ibm.com>
<4D99C61E.3080600@redhat.com> <4D99C9ED.3020602@codemonkey.ws>
<4D9A05D1.1000501@gmail.com>
<4D9AABE1.9030609@gmail.com>
Message-ID:
On Tue, Apr 5, 2011 at 6:42 AM, David Ahern wrote:
> On 04/04/11 23:33, Stefan Hajnoczi wrote:
>> On Mon, Apr 4, 2011 at 6:54 PM, David Ahern wrote:
>>> On 04/04/11 07:38, Anthony Liguori wrote:
>>>> On 04/04/2011 08:22 AM, Avi Kivity wrote:
>>>>> On 04/03/2011 02:57 PM, Stefan Hajnoczi wrote:
>>>>>> In order for media change to work with Linux host CD-ROM it is
>>>>>> necessary to reopen the file (otherwise the inode size will not
>>>>>> refresh, this is an issue with existing kernels).
>>>>>>
>>>>>
>>>>> Maybe we should fix the bug in Linux (and backport as necessary)?
>>>>>
>>>>> I think cd-rom assignment is sufficiently obscure that we can require
>>>>> a fixed kernel instead of providing a workaround.
>>>>
>>>> Do reads fail after CD change? ?Or do they succeed and the size is just
>>>> reported incorrectly?
>>>>
>>>> If it's the later, I'd agree that it needs fixing in the kernel. ?If
>>>> it's the former, I'd say it's clearly a feature.
>>>
>>> In January 2010 I was seeing old data -- data from the prior CD -- in
>>> the guest after the media change.
>>
>> Yikes. ?Is there a bug report for this? ?What are the steps to reproduce it?
>
> Not that I know of. It is reported by someone else last year as well:
> http://www.mail-archive.com/kvm at vger.kernel.org/msg32999.html
Thanks for the link. That looks like typical symptoms of missing
media change (which can also legitimately happen if the guest does not
poll). This should be fixed once the CD-ROM fixes are merged into
QEMU and Linux.
Stefan
From jdenemar at redhat.com Tue Apr 5 14:09:10 2011
From: jdenemar at redhat.com (Jiri Denemark)
Date: Tue, 5 Apr 2011 16:09:10 +0200
Subject: [libvirt] [PATCH] qemu: Support for overriding NPROC limit
Message-ID:
This patch adds max_processes option to qemu.conf which can be used to
override system default limit on number of processes that are allowed to
be running for qemu user.
---
src/qemu/libvirtd_qemu.aug | 3 +++
src/qemu/qemu.conf | 7 +++++++
src/qemu/qemu_conf.c | 4 ++++
src/qemu/qemu_conf.h | 2 ++
src/qemu/qemu_process.c | 24 ++++++++++++++++++++++++
src/qemu/test_libvirtd_qemu.aug | 4 ++++
6 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug
index affd74e..ac30b8e 100644
--- a/src/qemu/libvirtd_qemu.aug
+++ b/src/qemu/libvirtd_qemu.aug
@@ -13,11 +13,13 @@ module Libvirtd_qemu =
let str_val = del /\"/ "\"" . store /[^\"]*/ . del /\"/ "\""
let bool_val = store /0|1/
+ let int_val = store /[0-9]+/
let str_array_element = [ seq "el" . str_val ] . del /[ \t\n]*/ ""
let str_array_val = counter "el" . array_start . ( str_array_element . ( array_sep . str_array_element ) * ) ? . array_end
let str_entry (kw:string) = [ key kw . value_sep . str_val ]
let bool_entry (kw:string) = [ key kw . value_sep . bool_val ]
+ let int_entry (kw:string) = [ key kw . value_sep . int_val ]
let str_array_entry (kw:string) = [ key kw . value_sep . str_array_val ]
@@ -45,6 +47,7 @@ module Libvirtd_qemu =
| bool_entry "clear_emulator_capabilities"
| bool_entry "allow_disk_format_probing"
| bool_entry "set_process_name"
+ | int_entry "max_processes"
(* Each enty in the config is one of the following three ... *)
let entry = vnc_entry
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index 364f555..c70050e 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -273,3 +273,10 @@
# its arguments) appear in process listings.
#
# set_process_name = 1
+
+
+# If max_processes is set to a positive integer, libvirt will use it to set
+# maximum number of processes that can be run by qemu user. This can be used to
+# override default value set by host OS.
+#
+# max_processes = 0
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 9ba60b1..bb5421b 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -424,6 +424,10 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
CHECK_TYPE ("set_process_name", VIR_CONF_LONG);
if (p) driver->setProcessName = p->l;
+ p = virConfGetValue(conf, "max_processes");
+ CHECK_TYPE("max_processes", VIR_CONF_LONG);
+ if (p) driver->maxProcesses = p->l;
+
virConfFree (conf);
return 0;
}
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 7c6fde7..94918f6 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -105,6 +105,8 @@ struct qemud_driver {
unsigned int allowDiskFormatProbing : 1;
unsigned int setProcessName : 1;
+ int maxProcesses;
+
virCapsPtr caps;
/* An array of callbacks */
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 48ecd5c..9ada24d 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -25,6 +25,8 @@
#include
#include
#include
+#include
+#include
#include "qemu_process.h"
#include "qemu_domain.h"
@@ -1811,6 +1813,25 @@ qemuProcessPrepareChardevDevice(virDomainDefPtr def ATTRIBUTE_UNUSED,
}
+static int
+qemuProcessLimits(struct qemud_driver *driver)
+{
+ if (driver->maxProcesses > 0) {
+ struct rlimit rlim;
+
+ rlim.rlim_cur = rlim.rlim_max = driver->maxProcesses;
+ if (setrlimit(RLIMIT_NPROC, &rlim) < 0) {
+ virReportSystemError(errno,
+ _("cannot limit number of processes to %d"),
+ driver->maxProcesses);
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+
struct qemuProcessHookData {
virConnectPtr conn;
virDomainObjPtr vm;
@@ -1821,6 +1842,9 @@ static int qemuProcessHook(void *data)
{
struct qemuProcessHookData *h = data;
+ if (qemuProcessLimits(h->driver) < 0)
+ return -1;
+
/* This must take place before exec(), so that all QEMU
* memory allocation is on the correct NUMA node
*/
diff --git a/src/qemu/test_libvirtd_qemu.aug b/src/qemu/test_libvirtd_qemu.aug
index 8e477f5..917bd4f 100644
--- a/src/qemu/test_libvirtd_qemu.aug
+++ b/src/qemu/test_libvirtd_qemu.aug
@@ -111,6 +111,8 @@ clear_emulator_capabilities = 0
allow_disk_format_probing = 1
vnc_auto_unix_socket = 1
+
+max_processes = 12345
"
test Libvirtd_qemu.lns get conf =
@@ -232,3 +234,5 @@ vnc_auto_unix_socket = 1
{ "allow_disk_format_probing" = "1" }
{ "#empty" }
{ "vnc_auto_unix_socket" = "1" }
+{ "#empty" }
+{ "max_processes" = "12345" }
--
1.7.4.1
From eblake at redhat.com Tue Apr 5 14:25:26 2011
From: eblake at redhat.com (Eric Blake)
Date: Tue, 05 Apr 2011 08:25:26 -0600
Subject: [libvirt] [PATCH v3] Improve SCSI volume key generation
In-Reply-To: <1302001854-2218-1-git-send-email-berrange@redhat.com>
References: <1302001854-2218-1-git-send-email-berrange@redhat.com>
Message-ID: <4D9B2656.5020402@redhat.com>
On 04/05/2011 05:10 AM, Daniel P. Berrange wrote:
> The SCSI volumes get a better 'key' field based on the fully
> qualified volume path. All SCSI volumes have a unique serial
> available in hardware which can be obtained by sending a
> suitable SCSI command. Call out to udev's 'scsi_id' command
> to fetch this value
>
> In v3:
>
> - Use virCommandSetOutputBuffer/virCommandRun instead
> of VIR_FDOPEN
> - Skip serial if it matches empty string
>
> * src/storage/storage_backend_scsi.c: Improve volume key
> field value stability and uniqueness
> ---
> src/storage/storage_backend_scsi.c | 45 ++++++++++++++++++++++++++++++++---
> 1 files changed, 41 insertions(+), 4 deletions(-)
>
> +#ifdef HAVE_UDEV
> + virCommandPtr cmd = virCommandNewArgList(
> + "/lib/udev/scsi_id",
> + "--replace-whitespace",
> + "--whitelisted",
> + "--device", dev,
> + NULL
> + );
> +
> + /* Run the program and capture its output */
> + virCommandSetOutputBuffer(cmd, &serial);
> + if (virCommandRun(cmd, NULL) < 0)
> + goto cleanup;
> +#endif
> +
> + if (serial && STRNEQ(serial, "")) {
> + char *nl = strchr(serial, '\n');
> + if (nl)
> + *nl = '\0';
> + } else {
> + VIR_FREE(serial);
> + if (!(serial = strdup(dev)))
> + virReportOOMError();
> + }
> +
> +#ifdef HAVE_UDEV
> +cleanup:
> + virCommandFree(cmd);
> +#endif
It seems a bit weird to have two #ifdef sections; but I don't see any
easy way to consolidate them and still properly return failure on a
failed virCommandRun.
ACK.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From eblake at redhat.com Tue Apr 5 14:50:30 2011
From: eblake at redhat.com (Eric Blake)
Date: Tue, 05 Apr 2011 08:50:30 -0600
Subject: [libvirt] [PATCH] virsh: Fix a problem of argv parsing
In-Reply-To: <1302007127-16185-1-git-send-email-jyang@redhat.com>
References: <1302007127-16185-1-git-send-email-jyang@redhat.com>
Message-ID: <4D9B2C36.4060205@redhat.com>
On 04/05/2011 06:38 AM, Osier Yang wrote:
> Problem example:
> # virsh -d 5 vol-create --pool default col.xml
> vol-create: pool(optdata): default
> vol-create: pool(optdata): col.xml
> error: command 'vol-create' requires option
>
> It gets same "vshCmdOptDef" for both "--pool default"
> and "col.xml".
>
> This patch fixes it by increase "data_ct" when things like
> "--pool default" is successfully parsed, so that could
> get right "vshCmdOptDef" for the other arguments which
> are not with option name together.
While I agree that this patch appears to fix the problem, I'd feel much
better if we _also_ added a test case to prove we don't regress in the
future (especially since we might be making future changes to argument
parsing to improve tab-completion or unambiguous prefix support).
It looks like the following are impacted (at least these are the
commands with more than one VSH_OT_DATA/VSH_OFLAG_REQ option):
domblkstat
domifstat
domblkinfo
save
dump
vcpupin
setvcpus
setmem
setmaxmem
domxml-from-native
domxml-to-native
migrate
migrate-setmaxdowntime
pool-define-as
pool-create-as
vol-create-as
vol-create
vol-create-from
vol-clone
vol-upload
vol-download
secret-set-value
attach-device
detach-device
update-device
attach-interface
detach-interface
attach-disk
detach-disk
snapshot-dumpxml
snapshot-revert
snapshot-delete
qemu-monitor-command
And since test:///default supports setvcpus, a valid test might be to
copy the layout of virsh-schedinfo as framework, and test that all of
these are equivalent:
virsh -c test:///default setvcpus test 2
virsh -c test:///default setvcpus --domain test 2
virsh -c test:///default setvcpus --domain=test 2
virsh -c test:///default setvcpus test --count 2
virsh -c test:///default setvcpus test --count=2
virsh -c test:///default setvcpus --domain test --count 2
virsh -c test:///default setvcpus --domain=test --count 2
virsh -c test:///default setvcpus --domain test --count=2
virsh -c test:///default setvcpus --domain=test --count=2
virsh -c test:///default setvcpus --count 2 --domain test
virsh -c test:///default setvcpus --count 2 --domain=test
virsh -c test:///default setvcpus --count=2 --domain test
virsh -c test:///default setvcpus --count=2 --domain=test
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From mcastrol at gmail.com Tue Apr 5 14:54:05 2011
From: mcastrol at gmail.com (=?ISO-8859-1?Q?Marcela_Castro_Le=F3n?=)
Date: Tue, 5 Apr 2011 16:54:05 +0200
Subject: [libvirt] Using Restore in another host.
In-Reply-To: <4D9AFF24.6060109@redhat.com>
References:
<20110404102013.GB13616@redhat.com>
<4D9AFF24.6060109@redhat.com>
Message-ID:
Hello
This is the log I got doing the restore. It's says that it coun't get the
image, but the image is ok, because I can startup the guest.
Neither I can migrate the guest, so I suppose I've a problem in my
configuration.
Thank you very much in advance.
Marcela.
2011/4/5 Michal Novotny
> Hi Marcela,
> is any other guest on the host that cannot restore this VM working fine ?
>
> You could also try running the:
>
> */# LIBVIRT_DEBUG=1 virsh restore sv-chubut-2011-04-04-17:38 2>
> virsh-restore.log
>
> /*command which would enable the libvirt logging and output the debug
> log into the virsh-restore.log file. This file could be sent to the list
> for analysis what's wrong.
>
> Thanks,
> Michal
>
> On 04/05/2011 11:57 AM, Marcela Castro Le?n wrote:
> > Hello Daniel
> > Thank you for all your information, but I still didn't solve the
> > problem. I tried the option you mention, with two differents guest
> > into two differents host, but all the cases I've got:
> >
> > */virsh # restore sv-chubut-2011-04-04-17:38/*
> > */error: Failed to restore domain from sv-chubut-2011-04-04-17:38/*
> > */error: monitor socket did not show up.: Connection refused/*
> >
> > I cannot get any useful information (at least form me) on the log you
> > mention.
> > I'd appreciate a lot a new suggestion.
> > Thanks
> > Marcela
> >
> >
> >
> >
> > 2011/4/4 Daniel P. Berrange > >
> >
> > On Sun, Apr 03, 2011 at 10:43:45AM +0200, Marcela Castro Le?n wrote:
> > > Hello:
> > > I need to know if I can use the restore operation (virsh o the
> > equivalent in
> > > libvirt) to recover a previous state of a guest, but recovered
> > previously in
> > > another host.
> > > I did a test, but I got an error:
> > >
> > > The exactly sequence using virsh I testes is:
> > > On [HOST SOURCE]: Using virsh
> > > 1) save [domain] [file]
> > > 2) restore file
> > > 3) destroy [domain]
> > >
> > > On [HOST SOURCE] using ubuntu sh
> > > 4) cp [guest.img] [guest.xml] [file] to HOST2
> > >
> > > On [HOST TARGET] using virsh
> > > 5) define [guest.xml] (using image on destination in HOST2)
> > > 6) restore [file]
> >
> > As a general rule you should only ever 'restore' from a
> > file *once*. This is because after the first restore
> > operation, the guest may have made writes to its disk.
> > Restoring a second time the guest OS will likely have
> > an inconsistent view of the disk & will cause filesystem
> > corruption.
> >
> > If you want to be able to restore from a saved image
> > multiple times, you need to also take a snapshot of
> > the disk image at the same time, and restore that
> > snapshot when restoring the memory image.
> >
> >
> > That aside, saving on one host & restoring on a
> > different host is fine. So if you leave out steps
> > 2+3 in your example above, then your data would
> > still be safe.
> >
> > > The restore troughs the following message:
> > > *virsh # restore sv-chubut-2011-04-01-09:58
> > > error: Failed to restore domain from sv-chubut-2011-04-01-09:58
> > > error: monitor socket did not show up.: Connection refused*
> >
> > There is probably some configuration difference on your 2nd host
> > that prevented the VM from starting up. If you're lucky the file
> > /var/log/libvirt/qemu/$NAME.log will tell you more
> >
> > Daniel
> > --
> > |: http://berrange.com -o-
> > http://www.flickr.com/photos/dberrange/ :|
> > |: http://libvirt.org -o-
> > http://virt-manager.org :|
> > |: http://autobuild.org -o-
> > http://search.cpan.org/~danberr/
> > :|
> > |: http://entangle-photo.org -o-
> > http://live.gnome.org/gtk-vnc :|
> >
> >
> >
> > --
> > libvir-list mailing list
> > libvir-list at redhat.com
> > https://www.redhat.com/mailman/listinfo/libvir-list
>
>
> --
> Michal Novotny , RHCE
> Virtualization Team (xen userspace), Red Hat
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: restore_sv-chubut-2011-04-04-17:38.log
Type: text/x-log
Size: 6075 bytes
Desc: not available
URL:
From eblake at redhat.com Tue Apr 5 14:55:01 2011
From: eblake at redhat.com (Eric Blake)
Date: Tue, 05 Apr 2011 08:55:01 -0600
Subject: [libvirt] [PATCH] qemu: Do not unlink managedsave image if
restoring fails.
In-Reply-To: <20110405132037.GC7195@orkuz.home>
References: <1301986042-13725-1-git-send-email-jyang@redhat.com>
<20110405132037.GC7195@orkuz.home>
Message-ID: <4D9B2D45.4020606@redhat.com>
On 04/05/2011 07:20 AM, Jiri Denemark wrote:
> On Tue, Apr 05, 2011 at 14:47:22 +0800, Osier Yang wrote:
>> Both "qemuDomainStartWithFlags" and "qemuAutostartDomain" try to
>> restore the domain from managedsave'ed image if it exists (by
>> invoking "qemuDomainObjRestore"), but it unlinks the image even
>> if restoring fails, which causes data loss.
>>
>> However, I'm not sure if it's the very correct way to fix it,
>> if restoring fails, and we didn't remove the image, it will
>> trys to restore from the image again next time, if that's
>> not the user expected (e.g. the user made quite many changes
>> on the guest), then it's a new problem.
>
> I think this patch is risky. You should either remove the state on error
> (which is the current state) or fail domain start if managed state is present
> but resuming from it fails. If you do something in the middle (your patch) you
> will certainly end up corrupting domain's disks.
What's more, I think we should consider removing the saved-state file on
success for 'virsh restore file' - once a state has been restored, the
guest is running and has likely modified its disks, which means that the
saved (memory) state is no longer consistent with the new disk state,
and a second restore of the saved file is asking for a different type of
data corruption.
That is, I think:
virsh save dom file
virsh restore file
should leave file intact if and only if the restore failed, and:
virsh managedsave dom
virsh start
should either fail but leave the (hidden) state file intact, or succeed
and remove the state file. We have virsh managedsave-remove to properly
delete the state file if the user determines that they want a fresh
start rather than retrying the (hidden) state file.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From mcastrol at gmail.com Tue Apr 5 15:01:00 2011
From: mcastrol at gmail.com (=?ISO-8859-1?Q?Marcela_Castro_Le=F3n?=)
Date: Tue, 5 Apr 2011 17:01:00 +0200
Subject: [libvirt] LIBVIRT migration
In-Reply-To:
References:
<20110401142611.GK29510@redhat.com>
Message-ID:
Hello:
I did more tests, but I don't find the problem.
this is a debug I've got setting LIBVIRT_DEBUG=1, I'd appreciate any help.
Regards.
Marcela.
2011/4/4 Marcela Castro Le?n
> Hello
> I'm having problem using migration. I'm working on ubuntu 10.4 and this
> versions of libvirt and virsh:
> virsh # version
> Compiled against library: libvir 0.7.5
> Using library: libvir 0.7.5
> Using API: QEMU 0.7.5
> Running hypervisor: QEMU 0.12.3
>
> This is the error.
> *virsh # migrate scompi1 qemu+ssh://rionegro/system
> error: Unknown failure
> *
>
> This is the log on the destination, that show that there is no
> communication problem, but it has a problem starting the guest on
> destination.
>
> radic at rionegro:~$ sudo cat /var/log/libvirt/qemu/scompi1.log
> [sudo] password for radic:
> LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
> QEMU_AUDIO_DRV=none /usr/bin/qemu-system-x86_64 -S -M pc-0.12 -enable-kvm -m
> 4096 -smp 4 -name scompi1 -uuid 355123af-b683-9fa6-ca31-10506c9ab9da
> -chardev
> socket,id=monitor,path=/var/lib/libvirt/qemu/scompi1.monitor,server,nowait
> -monitor chardev:monitor -boot c -drive
> file=/home/radic/mvdata/imagenes/scompi1.img,if=ide,index=0,boot=on,format=raw
> -drive if=ide,media=cdrom,index=2,format=raw -net
> nic,macaddr=52:54:00:05:d1:2a,vlan=0,model=virtio,name=virtio.0 -net
> tap,fd=33,vlan=0,name=tap.0 -chardev pty,id=serial0 -serial chardev:serial0
> -parallel none -usb -vnc 127.0.0.1:0 -vga cirrus -incoming tcp:
> 0.0.0.0:49153
> char device redirected to /dev/pts/1
> LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
> QEMU_AUDIO_DRV=none /usr/bin/qemu-system-x86_64 -S -M pc-0.12 -enable-kvm -m
> 4096 -smp 4 -name scompi1 -uuid 355123af-b683-9fa6-ca31-10506c9ab9da
> -chardev
> socket,id=monitor,path=/var/lib/libvirt/qemu/scompi1.monitor,server,nowait
> -monitor chardev:monitor -boot c -drive
> file=/home/radic/mvdata/imagenes/scompi1.img,if=ide,index=0,boot=on,format=raw
> -drive if=ide,media=cdrom,index=2,format=raw -net
> nic,macaddr=52:54:00:05:d1:2a,vlan=0,model=virtio,name=virtio.0 -net
> tap,fd=33,vlan=0,name=tap.0 -chardev pty,id=serial0 -serial chardev:serial0
> -parallel none -usb -vnc 127.0.0.1:0 -vga cirrus -incoming tcp:
> 0.0.0.0:49154
> char device redirected to /dev/pts/2
> LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
> QEMU_AUDIO_DRV=none /usr/bin/qemu-system-x86_64 -S -M pc-0.12 -enable-kvm -m
> 4096 -smp 4 -name scompi1 -uuid 355123af-b683-9fa6-ca31-10506c9ab9da
> -chardev
> socket,id=monitor,path=/var/lib/libvirt/qemu/scompi1.monitor,server,nowait
> -monitor chardev:monitor -boot c -drive
> file=/home/radic/mvdata/imagenes/scompi1.img,if=ide,index=0,boot=on,format=raw
> -drive if=ide,media=cdrom,index=2,format=raw -net
> nic,macaddr=52:54:00:05:d1:2a,vlan=0,model=virtio,name=virtio.0 -net
> tap,fd=33,vlan=0,name=tap.0 -chardev pty,id=serial0 -serial chardev:serial0
> -parallel none -usb -vnc 127.0.0.1:0 -vga cirrus -incoming tcp:
> 0.0.0.0:49155
> char device redirected to /dev/pts/2
>
> I'm attaching the xml of the scompi1 that i'm trying to migrate.
> I'd apprciate a lot any help.
> Marcela
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mig_rionegro-1.log
Type: text/x-log
Size: 6071 bytes
Desc: not available
URL:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mig_chubut-1.log
Type: text/x-log
Size: 6071 bytes
Desc: not available
URL:
From berrange at redhat.com Tue Apr 5 15:03:07 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Tue, 5 Apr 2011 16:03:07 +0100
Subject: [libvirt] [PATCH 1/3] Don't use virSetCloseExec in event loop on
Win32
Message-ID: <1302015789-488-1-git-send-email-berrange@redhat.com>
The virSetCloseExec API returns -1 on Win32 since it cannot
possibly work. Avoid calling it from the event loop since
is not required in this case.
* src/util/event_poll.c: Remove virSetCloseExec
---
src/util/event_poll.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/util/event_poll.c b/src/util/event_poll.c
index 91000e2..90788a4 100644
--- a/src/util/event_poll.c
+++ b/src/util/event_poll.c
@@ -658,10 +658,12 @@ int virEventPollInit(void)
}
if (pipe(eventLoop.wakeupfd) < 0 ||
- virSetNonBlock(eventLoop.wakeupfd[0]) < 0 ||
- virSetNonBlock(eventLoop.wakeupfd[1]) < 0 ||
+#ifndef WIN32
virSetCloseExec(eventLoop.wakeupfd[0]) < 0 ||
- virSetCloseExec(eventLoop.wakeupfd[1]) < 0) {
+ virSetCloseExec(eventLoop.wakeupfd[1]) < 0 ||
+#endif
+ virSetNonBlock(eventLoop.wakeupfd[0]) < 0 ||
+ virSetNonBlock(eventLoop.wakeupfd[1]) < 0) {
virReportSystemError(errno, "%s",
_("Unable to setup wakeup pipe"));
return -1;
--
1.7.4
From berrange at redhat.com Tue Apr 5 15:03:08 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Tue, 5 Apr 2011 16:03:08 +0100
Subject: [libvirt] [PATCH 2/3] Avoid compiler warnings about int -> void *
casts
In-Reply-To: <1302015789-488-1-git-send-email-berrange@redhat.com>
References: <1302015789-488-1-git-send-email-berrange@redhat.com>
Message-ID: <1302015789-488-2-git-send-email-berrange@redhat.com>
GCC is a little confused about the cast of beginthread/beginthreadex
from unsigned long -> void *. Go via an intermediate variable avoids
the bogus warning, and makes the code a little cleaner
* src/util/threads-win32.c: Avoid compiler warning in cast
---
src/util/threads-win32.c | 18 +++++++++++-------
1 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/src/util/threads-win32.c b/src/util/threads-win32.c
index ddb4737..5661437 100644
--- a/src/util/threads-win32.c
+++ b/src/util/threads-win32.c
@@ -262,6 +262,7 @@ int virThreadCreate(virThreadPtr thread,
void *opaque)
{
struct virThreadArgs *args;
+ uintptr_t ret;
if (VIR_ALLOC(args) < 0)
return -1;
@@ -271,17 +272,20 @@ int virThreadCreate(virThreadPtr thread,
thread->joinable = joinable;
if (joinable) {
- thread->thread = (HANDLE)_beginthreadex(NULL, 0,
- virThreadHelperJoinable,
- args, 0, NULL);
- if (thread->thread == 0)
+ ret = _beginthreadex(NULL, 0,
+ virThreadHelperJoinable,
+ args, 0, NULL);
+ if (ret == 0)
return -1;
} else {
- thread->thread = (HANDLE)_beginthread(virThreadHelperDaemon,
- 0, args);
- if (thread->thread == (HANDLE)-1L)
+ ret = _beginthread(virThreadHelperDaemon,
+ 0, args);
+ if (ret == -1L)
return -1;
}
+
+ thread->thread = (HANDLE)ret;
+
return 0;
}
--
1.7.4
From berrange at redhat.com Tue Apr 5 15:03:09 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Tue, 5 Apr 2011 16:03:09 +0100
Subject: [libvirt] [PATCH 3/3] Don't try to enable stack protector on Win32
In-Reply-To: <1302015789-488-1-git-send-email-berrange@redhat.com>
References: <1302015789-488-1-git-send-email-berrange@redhat.com>
Message-ID: <1302015789-488-3-git-send-email-berrange@redhat.com>
The GCC Win32 compiler will claim to support -fstack-protector,
but if it actually gets triggered by a suitable code pattern,
linking will fail. Other non-Linux OS likely suffer the same
way with gcc.
* m4/virt-compile-warnings.m4: Only use stack protector when
the build target is Linux.
---
m4/virt-compile-warnings.m4 | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4
index 7e252d5..819da8f 100644
--- a/m4/virt-compile-warnings.m4
+++ b/m4/virt-compile-warnings.m4
@@ -98,11 +98,17 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
# Extra special flags
gl_WARN_ADD([-Wp,-D_FORTIFY_SOURCE=2])
- dnl Fedora only uses -fstack-protector, but doesn't seem to
- dnl be great overhead in adding -fstack-protector-all instead
- dnl gl_WARN_ADD([-fstack-protector])
- gl_WARN_ADD([-fstack-protector-all])
- gl_WARN_ADD([--param=ssp-buffer-size=4])
+ dnl -fstack-protector stuff passes gl_WARN_ADD with gcc
+ dnl on Mingw32, but fails when actually used
+ case $host in
+ *-*-linux*)
+ dnl Fedora only uses -fstack-protector, but doesn't seem to
+ dnl be great overhead in adding -fstack-protector-all instead
+ dnl gl_WARN_ADD([-fstack-protector])
+ gl_WARN_ADD([-fstack-protector-all])
+ gl_WARN_ADD([--param=ssp-buffer-size=4])
+ ;;
+ esac
gl_WARN_ADD([-fexceptions])
gl_WARN_ADD([-fasynchronous-unwind-tables])
gl_WARN_ADD([-fdiagnostics-show-option])
--
1.7.4
From minovotn at redhat.com Tue Apr 5 15:09:46 2011
From: minovotn at redhat.com (Michal Novotny)
Date: Tue, 05 Apr 2011 17:09:46 +0200
Subject: [libvirt] Using Restore in another host.
In-Reply-To:
References: <20110404102013.GB13616@redhat.com> <4D9AFF24.6060109@redhat.com>
Message-ID: <4D9B30BA.6090906@redhat.com>
Hi Marcela,
I was investigating the log file and it seems like the image file cannot
be opened on the remote host.
According to the lost you're doing the restore on the host named
rionegro so not the localhost. This seems like the saved guest image is
not accessible from the rionegro system. Could you please try to connect
to rionegro system using SSH and then connect to the default system
hypervisor using:
# virsh restore
with no specification of remote system to connect to the default
hypervisor (default is qemu:///system under root account).
Also, what may be causing issues is the colon character (':') AFAIK so
try renaming the image from sv-chubut-2011-04-04-17:38 to some other
name without spaces and colon characters, e.g. to
sv-chubut-2011-04-04-17-38 and try to restore this way.
Since according to the code it's about opening file error I guess the
remote system is not having access to the file.
Michal
On 04/05/2011 04:54 PM, Marcela Castro Le?n wrote:
> Hello
> This is the log I got doing the restore. It's says that it coun't get
> the image, but the image is ok, because I can startup the guest.
> Neither I can migrate the guest, so I suppose I've a problem in my
> configuration.
> Thank you very much in advance.
> Marcela.
>
> 2011/4/5 Michal Novotny >
>
> Hi Marcela,
> is any other guest on the host that cannot restore this VM working
> fine ?
>
> You could also try running the:
>
> */# LIBVIRT_DEBUG=1 virsh restore sv-chubut-2011-04-04-17:38 2>
> virsh-restore.log
>
> /*command which would enable the libvirt logging and output the debug
> log into the virsh-restore.log file. This file could be sent to
> the list
> for analysis what's wrong.
>
> Thanks,
> Michal
>
> On 04/05/2011 11:57 AM, Marcela Castro Le?n wrote:
> > Hello Daniel
> > Thank you for all your information, but I still didn't solve the
> > problem. I tried the option you mention, with two differents guest
> > into two differents host, but all the cases I've got:
> >
> > */virsh # restore sv-chubut-2011-04-04-17:38/*
> > */error: Failed to restore domain from sv-chubut-2011-04-04-17:38/*
> > */error: monitor socket did not show up.: Connection refused/*
> >
> > I cannot get any useful information (at least form me) on the
> log you
> > mention.
> > I'd appreciate a lot a new suggestion.
> > Thanks
> > Marcela
> >
> >
> >
> >
> > 2011/4/4 Daniel P. Berrange
> > >>
> >
> > On Sun, Apr 03, 2011 at 10:43:45AM +0200, Marcela Castro
> Le?n wrote:
> > > Hello:
> > > I need to know if I can use the restore operation (virsh o the
> > equivalent in
> > > libvirt) to recover a previous state of a guest, but recovered
> > previously in
> > > another host.
> > > I did a test, but I got an error:
> > >
> > > The exactly sequence using virsh I testes is:
> > > On [HOST SOURCE]: Using virsh
> > > 1) save [domain] [file]
> > > 2) restore file
> > > 3) destroy [domain]
> > >
> > > On [HOST SOURCE] using ubuntu sh
> > > 4) cp [guest.img] [guest.xml] [file] to HOST2
> > >
> > > On [HOST TARGET] using virsh
> > > 5) define [guest.xml] (using image on destination in HOST2)
> > > 6) restore [file]
> >
> > As a general rule you should only ever 'restore' from a
> > file *once*. This is because after the first restore
> > operation, the guest may have made writes to its disk.
> > Restoring a second time the guest OS will likely have
> > an inconsistent view of the disk & will cause filesystem
> > corruption.
> >
> > If you want to be able to restore from a saved image
> > multiple times, you need to also take a snapshot of
> > the disk image at the same time, and restore that
> > snapshot when restoring the memory image.
> >
> >
> > That aside, saving on one host & restoring on a
> > different host is fine. So if you leave out steps
> > 2+3 in your example above, then your data would
> > still be safe.
> >
> > > The restore troughs the following message:
> > > *virsh # restore sv-chubut-2011-04-01-09:58
> > > error: Failed to restore domain from
> sv-chubut-2011-04-01-09:58
> > > error: monitor socket did not show up.: Connection refused*
> >
> > There is probably some configuration difference on your 2nd host
> > that prevented the VM from starting up. If you're lucky the file
> > /var/log/libvirt/qemu/$NAME.log will tell you more
> >
> > Daniel
> > --
> > |: http://berrange.com -o-
> > http://www.flickr.com/photos/dberrange/ :|
> > |: http://libvirt.org -o-
> > http://virt-manager.org :|
> > |: http://autobuild.org -o-
> > http://search.cpan.org/~danberr/
>
> > :|
> > |: http://entangle-photo.org -o-
> > http://live.gnome.org/gtk-vnc :|
> >
> >
> >
> > --
> > libvir-list mailing list
> > libvir-list at redhat.com
> > https://www.redhat.com/mailman/listinfo/libvir-list
>
>
> --
> Michal Novotny >,
> RHCE
> Virtualization Team (xen userspace), Red Hat
>
>
--
Michal Novotny , RHCE
Virtualization Team (xen userspace), Red Hat
From eblake at redhat.com Tue Apr 5 15:15:57 2011
From: eblake at redhat.com (Eric Blake)
Date: Tue, 05 Apr 2011 09:15:57 -0600
Subject: [libvirt] Using Restore in another host.
In-Reply-To: <4D9B30BA.6090906@redhat.com>
References: <20110404102013.GB13616@redhat.com> <4D9AFF24.6060109@redhat.com>
<4D9B30BA.6090906@redhat.com>
Message-ID: <4D9B322D.9040309@redhat.com>
On 04/05/2011 09:09 AM, Michal Novotny wrote:
> Hi Marcela,
> I was investigating the log file and it seems like the image file cannot
> be opened on the remote host.
Are you using SELinux, and is your shared storage on NFS? If so, did
you run 'setsebool -P virt_use_nfs on' to let the destination properly
access the shared storage from NFS?
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From minovotn at redhat.com Tue Apr 5 15:17:28 2011
From: minovotn at redhat.com (Michal Novotny)
Date: Tue, 05 Apr 2011 17:17:28 +0200
Subject: [libvirt] Using Restore in another host.
In-Reply-To: <4D9B322D.9040309@redhat.com>
References: <20110404102013.GB13616@redhat.com> <4D9AFF24.6060109@redhat.com>
<4D9B30BA.6090906@redhat.com> <4D9B322D.9040309@redhat.com>
Message-ID: <4D9B3288.6080700@redhat.com>
On 04/05/2011 05:15 PM, Eric Blake wrote:
> On 04/05/2011 09:09 AM, Michal Novotny wrote:
>> Hi Marcela,
>> I was investigating the log file and it seems like the image file cannot
>> be opened on the remote host.
> Are you using SELinux, and is your shared storage on NFS? If so, did
> you run 'setsebool -P virt_use_nfs on' to let the destination properly
> access the shared storage from NFS?
>
Eric, I'm not too familiar with SELinux. Do you think the
virFileOpenAs() would fail if the SELinux context won't be set properly?
Michal
--
Michal Novotny , RHCE
Virtualization Team (xen userspace), Red Hat
From eblake at redhat.com Tue Apr 5 15:19:30 2011
From: eblake at redhat.com (Eric Blake)
Date: Tue, 05 Apr 2011 09:19:30 -0600
Subject: [libvirt] [PATCH] qemu: Always reserves slot 0x02 for primary
VGA.
In-Reply-To: <1302011398-25541-1-git-send-email-jyang@redhat.com>
References: <1302011398-25541-1-git-send-email-jyang@redhat.com>
Message-ID: <4D9B3302.5010307@redhat.com>
On 04/05/2011 07:49 AM, Osier Yang wrote:
> To address https://bugzilla.redhat.com/show_bug.cgi?id=692355
>
> This fix is to reserve slot 0x02 for primary VGA even if there
> is no "video" specified in domain XML to avoid the problem.
> ---
> src/qemu/qemu_command.c | 13 ++++++++++---
> 1 files changed, 10 insertions(+), 3 deletions(-)
ACK. I think that this is the correct patch, given the earlier comments
on the same topic in
https://www.redhat.com/archives/libvir-list/2011-March/msg01296.html
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From berrange at redhat.com Tue Apr 5 15:19:28 2011
From: berrange at redhat.com (Daniel P. Berrange)
Date: Tue, 5 Apr 2011 16:19:28 +0100
Subject: [libvirt] [PATCH] Fix typo in systemtap tapset directrory name
Message-ID: <1302016768-18964-1-git-send-email-berrange@redhat.com>
The systemtap directory for tapsets is called
/usr/share/systemtap/tapset
Not
/usr/share/systemtap/tapsets
* daemon/Makefile.am,libvirt.spec.in: s/tapsets/tapset/
---
daemon/Makefile.am | 2 +-
libvirt.spec.in | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 0fde04c..cacec1c 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -165,7 +165,7 @@ nodist_libvirtd_SOURCES = probes.h
BUILT_SOURCES += probes.h
-tapsetdir = $(datadir)/systemtap/tapsets
+tapsetdir = $(datadir)/systemtap/tapset
tapset_DATA = libvirtd.stp
probes.h: probes.d
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 724b9b7..4162fba 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -898,7 +898,7 @@ fi
%config(noreplace) %{_sysconfdir}/sysconfig/libvirtd
%config(noreplace) %{_sysconfdir}/libvirt/libvirtd.conf
%if %{with_dtrace}
-%{_datadir}/systemtap/tapsets/libvirtd.stp
+%{_datadir}/systemtap/tapset/libvirtd.stp
%endif
%dir %attr(0700, root, root) %{_localstatedir}/log/libvirt/qemu/
%dir %attr(0700, root, root) %{_localstatedir}/log/libvirt/lxc/
--
1.7.4
From mcastrol at gmail.com Tue Apr 5 15:20:31 2011
From: mcastrol at gmail.com (=?ISO-8859-1?Q?Marcela_Castro_Le=F3n?=)
Date: Tue, 5 Apr 2011 17:20:31 +0200
Subject: [libvirt] Using Restore in another host.
In-Reply-To: <4D9B30BA.6090906@redhat.com>
References:
<20110404102013.GB13616@redhat.com>
<4D9AFF24.6060109@redhat.com>
<4D9B30BA.6090906@redhat.com>
Message-ID:
Hello
OK, this is the new log. Now, the old error appeared again...
*error: Failed to restore domain from XX
error: monitor socket did not show up.: Connection refused
*
Regards.
2011/4/5 Michal Novotny
> Hi Marcela,
> I was investigating the log file and it seems like the image file cannot
> be opened on the remote host.
>
> According to the lost you're doing the restore on the host named
> rionegro so not the localhost. This seems like the saved guest image is
> not accessible from the rionegro system. Could you please try to connect
> to rionegro system using SSH and then connect to the default system
> hypervisor using:
>
> # virsh restore
>
> with no specification of remote system to connect to the default
> hypervisor (default is qemu:///system under root account).
>
> Also, what may be causing issues is the colon character (':') AFAIK so
> try renaming the image from sv-chubut-2011-04-04-17:38 to some other
> name without spaces and colon characters, e.g. to
> sv-chubut-2011-04-04-17-38 and try to restore this way.
>
> Since according to the code it's about opening file error I guess the
> remote system is not having access to the file.
>
> Michal
>
> On 04/05/2011 04:54 PM, Marcela Castro Le?n wrote:
> > Hello
> > This is the log I got doing the restore. It's says that it coun't get
> > the image, but the image is ok, because I can startup the guest.
> > Neither I can migrate the guest, so I suppose I've a problem in my
> > configuration.
> > Thank you very much in advance.
> > Marcela.
> >
> > 2011/4/5 Michal Novotny >>
> >
> > Hi Marcela,
> > is any other guest on the host that cannot restore this VM working
> > fine ?
> >
> > You could also try running the:
> >
> > */# LIBVIRT_DEBUG=1 virsh restore sv-chubut-2011-04-04-17:38 2>
> > virsh-restore.log
> >
> > /*command which would enable the libvirt logging and output the debug
> > log into the virsh-restore.log file. This file could be sent to
> > the list
> > for analysis what's wrong.
> >
> > Thanks,
> > Michal
> >
> > On 04/05/2011 11:57 AM, Marcela Castro Le?n wrote:
> > > Hello Daniel
> > > Thank you for all your information, but I still didn't solve the
> > > problem. I tried the option you mention, with two differents guest
> > > into two differents host, but all the cases I've got:
> > >
> > > */virsh # restore sv-chubut-2011-04-04-17:38/*
> > > */error: Failed to restore domain from sv-chubut-2011-04-04-17:38/*
> > > */error: monitor socket did not show up.: Connection refused/*
> > >
> > > I cannot get any useful information (at least form me) on the
> > log you
> > > mention.
> > > I'd appreciate a lot a new suggestion.
> > > Thanks
> > > Marcela
> > >
> > >
> > >
> > >
> > > 2011/4/4 Daniel P. Berrange >
> > > >>
> > >
> > > On Sun, Apr 03, 2011 at 10:43:45AM +0200, Marcela Castro
> > Le?n wrote:
> > > > Hello:
> > > > I need to know if I can use the restore operation (virsh o
> the
> > > equivalent in
> > > > libvirt) to recover a previous state of a guest, but
> recovered
> > > previously in
> > > > another host.
> > > > I did a test, but I got an error:
> > > >
> > > > The exactly sequence using virsh I testes is:
> > > > On [HOST SOURCE]: Using virsh
> > > > 1) save [domain] [file]
> > > > 2) restore file
> > > > 3) destroy [domain]
> > > >
> > > > On [HOST SOURCE] using ubuntu sh
> > > > 4) cp [guest.img] [guest.xml] [file] to HOST2
> > > >
> > > > On [HOST TARGET] using virsh
> > > > 5) define [guest.xml] (using image on destination in HOST2)
> > > > 6) restore [file]
> > >
> > > As a general rule you should only ever 'restore' from a
> > > file *once*. This is because after the first restore
> > > operation, the guest may have made writes to its disk.
> > > Restoring a second time the guest OS will likely have
> > > an inconsistent view of the disk & will cause filesystem
> > > corruption.
> > >
> > > If you want to be able to restore from a saved image
> > > multiple times, you need to also take a snapshot of
> > > the disk image at the same time, and restore that
> > > snapshot when restoring the memory image.
> > >
> > >
> > > That aside, saving on one host & restoring on a
> > > different host is fine. So if you leave out steps
> > > 2+3 in your example above, then your data would
> > > still be safe.
> > >
> > > > The restore troughs the following message:
> > > > *virsh # restore sv-chubut-2011-04-01-09:58
> > > > error: Failed to restore domain from
> > sv-chubut-2011-04-01-09:58
> > > > error: monitor socket did not show up.: Connection refused*
> > >
> > > There is probably some configuration difference on your 2nd
> host
> > > that prevented the VM from starting up. If you're lucky the
> file
> > > /var/log/libvirt/qemu/$NAME.log will tell you more
> > >
> > > Daniel
> > > --
> > > |: http://berrange.com -o-
> > > http://www.flickr.com/photos/dberrange/ :|
> > > |: http://libvirt.org -o-
> > > http://virt-manager.org :|
> > > |: http://autobuild.org -o-
> > > http://search.cpan.org/~danberr/
> >
> > > :|
> > > |: http://entangle-photo.org -o-
> > > http://live.gnome.org/gtk-vnc :|
> > >
> > >
> > >
> > > --
> > > libvir-list mailing list
> > > libvir-list at redhat.com
> > > https://www.redhat.com/mailman/listinfo/libvir-list
> >
> >
> > --
> > Michal Novotny >,
> > RHCE
> > Virtualization Team (xen userspace), Red Hat
> >
> >
>
>
> --
> Michal Novotny , RHCE
> Virtualization Team (xen userspace), Red Hat
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
-------------- next part --------------
radic at rionegro:~/discoguest/mvdata/imagenes$ virsh
17:16:32.636: debug : virInitialize:336 : register drivers
17:16:32.636: debug : virRegisterDriver:837 : registering Test as driver 0
17:16:32.636: debug : virRegisterNetworkDriver:675 : registering Test as network driver 0
17:16:32.636: debug : virRegisterInterfaceDriver:706 : registering Test as interface driver 0
17:16:32.636: debug : virRegisterStorageDriver:737 : registering Test as storage driver 0
17:16:32.636: debug : virRegisterDeviceMonitor:768 : registering Test as device driver 0
17:16:32.636: debug : virRegisterSecretDriver:799 : registering Test as secret driver 0
17:16:32.637: debug : virRegisterDriver:837 : registering Xen as driver 1
17:16:32.637: debug : virRegisterDriver:837 : registering OPENVZ as driver 2
17:16:32.637: debug : vboxRegister:109 : VBoxCGlueInit failed, using dummy driver
17:16:32.637: debug : virRegisterDriver:837 : registering VBOX as driver 3
17:16:32.637: debug : virRegisterNetworkDriver:675 : registering VBOX as network driver 1
17:16:32.637: debug : virRegisterStorageDriver:737 : registering VBOX as storage driver 1
17:16:32.637: debug : virRegisterDriver:837 : registering remote as driver 4
17:16:32.637: debug : virRegisterNetworkDriver:675 : registering remote as network driver 2
17:16:32.637: debug : virRegisterInterfaceDriver:706 : registering remote as interface driver 1
17:16:32.637: debug : virRegisterStorageDriver:737 : registering remote as storage driver 2
17:16:32.637: debug : virRegisterDeviceMonitor:768 : registering remote as device driver 1
17:16:32.637: debug : virRegisterSecretDriver:799 : registering remote as secret driver 1
17:16:32.637: debug : virConnectOpenAuth:1337 : name=qemu:///system, auth=0x7ffcdc643b80, flags=0
17:16:32.637: debug : do_open:1106 : name "qemu:///system" to URI components:
scheme qemu
opaque (null)
authority (null)
server (null)
user (null)
port 0
path /system
17:16:32.637: debug : do_open:1116 : trying driver 0 (Test) ...
17:16:32.637: debug : do_open:1122 : driver 0 Test returned DECLINED
17:16:32.637: debug : do_open:1116 : trying driver 1 (Xen) ...
17:16:32.637: debug : do_open:1122 : driver 1 Xen returned DECLINED
17:16:32.637: debug : do_open:1116 : trying driver 2 (OPENVZ) ...
17:16:32.637: debug : do_open:1122 : driver 2 OPENVZ returned DECLINED
17:16:32.637: debug : do_open:1116 : trying driver 3 (VBOX) ...
17:16:32.637: debug : do_open:1122 : driver 3 VBOX returned DECLINED
17:16:32.637: debug : do_open:1116 : trying driver 4 (remote) ...
17:16:32.637: debug : doRemoteOpen:564 : proceeding with name = qemu:///system
17:16:32.637: debug : remoteIO:8455 : Do proc=66 serial=0 length=28 wait=(nil)
17:16:32.637: debug : remoteIO:8517 : We have the buck 66 0x7ffcdc896010 0x7ffcdc896010
17:16:32.638: debug : remoteIODecodeMessageLength:7939 : Got length, now need 64 total (60 more)
17:16:32.638: debug : remoteIOEventLoop:8381 : Giving up the buck 66 0x7ffcdc896010 (nil)
17:16:32.638: debug : remoteIO:8548 : All done with our call 66 (nil) 0x7ffcdc896010
17:16:32.638: debug : remoteIO:8455 : Do proc=1 serial=1 length=56 wait=(nil)
17:16:32.638: debug : remoteIO:8517 : We have the buck 1 0x10798e0 0x10798e0
17:16:32.638: debug : remoteIODecodeMessageLength:7939 : Got length, now need 56 total (52 more)
17:16:32.638: debug : remoteIOEventLoop:8381 : Giving up the buck 1 0x10798e0 (nil)
17:16:32.638: debug : remoteIO:8548 : All done with our call 1 (nil) 0x10798e0
17:16:32.638: debug : doRemoteOpen:917 : Adding Handler for remote events
17:16:32.638: debug : doRemoteOpen:924 : virEventAddHandle failed: No addHandleImpl defined. continuing without events.
17:16:32.638: debug : do_open:1122 : driver 4 remote returned SUCCESS
17:16:32.638: debug : do_open:1142 : network driver 0 Test returned DECLINED
17:16:32.638: debug : do_open:1142 : network driver 1 VBOX returned DECLINED
17:16:32.638: debug : do_open:1142 : network driver 2 remote returned SUCCESS
17:16:32.638: debug : do_open:1161 : interface driver 0 Test returned DECLINED
17:16:32.638: debug : do_open:1161 : interface driver 1 remote returned SUCCESS
17:16:32.638: debug : do_open:1181 : storage driver 0 Test returned DECLINED
17:16:32.638: debug : do_open:1181 : storage driver 1 VBOX returned DECLINED
17:16:32.638: debug : do_open:1181 : storage driver 2 remote returned SUCCESS
17:16:32.638: debug : do_open:1201 : node driver 0 Test returned DECLINED
17:16:32.638: debug : do_open:1201 : node driver 1 remote returned SUCCESS
17:16:32.638: debug : do_open:1228 : secret driver 0 Test returned DECLINED
17:16:32.638: debug : do_open:1228 : secret driver 1 remote returned SUCCESS
Welcome to virsh, the virtualization interactive terminal.
Type: 'help' for help with commands
'quit' to quit
virsh # restore XX
17:16:36.271: debug : virDomainRestore:2283 : conn=0x1074070, from=XX
17:16:36.271: debug : remoteIO:8455 : Do proc=54 serial=2 length=76 wait=(nil)
17:16:36.271: debug : remoteIO:8517 : We have the buck 54 0x1094fc0 0x1094fc0
17:17:06.724: debug : remoteIODecodeMessageLength:7939 : Got length, now need 192 total (188 more)
17:17:06.724: debug : remoteIOEventLoop:8381 : Giving up the buck 54 0x1094fc0 (nil)
17:17:06.724: debug : remoteIO:8548 : All done with our call 54 (nil) 0x1094fc0
error: Failed to restore domain from XX
error: monitor socket did not show up.: Connection refused
virsh #
From minovotn at redhat.com Tue Apr 5 15:22:08 2011
From: minovotn at redhat.com (Michal Novotny)
Date: Tue, 05 Apr 2011 17:22:08 +0200
Subject: [libvirt] LIBVIRT migration
In-Reply-To:
References: <20110401142611.GK29510@redhat.com>
Message-ID: <4D9B33A0.5010903@redhat.com>
[snip]
Are you sure the domain name is OK for the case of this attempt where
you got the log files ?
error: failed to get domain 'scmpich1'
error: Domain not found: no domain with matching name 'scmpich1'
This seems like the domain doesn't exist neither on source nor on target system.
Michal
--
Michal Novotny , RHCE
Virtualization Team (xen userspace), Red Hat
From mcastrol at gmail.com Tue Apr 5 15:25:08 2011
From: mcastrol at gmail.com (=?ISO-8859-1?Q?Marcela_Castro_Le=F3n?=)
Date: Tue, 5 Apr 2011 17:25:08 +0200
Subject: [libvirt] Using Restore in another host.
In-Reply-To: <4D9B322D.9040309@redhat.com>
References:
<20110404102013.GB13616@redhat.com>
<4D9AFF24.6060109@redhat.com>
<4D9B30BA.6090906@redhat.com> <4D9B322D.9040309@redhat.com>
Message-ID:
Hello
I don't do this, I'd find out about it and set it. But, i don't know if this
avoid the error, but I'm trying to restore the image from the host that is
nfs server.
I will execute, try again and tell you if I succeed.
Thank you.
Marcela
2011/4/5 Eric Blake
> On 04/05/2011 09:09 AM, Michal Novotny wrote:
> > Hi Marcela,
> > I was investigating the log file and it seems like the image file cannot
> > be opened on the remote host.
>
> Are you using SELinux, and is your shared storage on NFS? If so, did
> you run 'setsebool -P virt_use_nfs on' to let the destination properly
> access the shared storage from NFS?
>
> --
> Eric Blake eblake at redhat.com +1-801-349-2682
> Libvirt virtualization library http://libvirt.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From eblake at redhat.com Tue Apr 5 15:28:00 2011
From: eblake at redhat.com (Eric Blake)
Date: Tue, 05 Apr 2011 09:28:00 -0600
Subject: [libvirt] [PATCH] qemu: Support for overriding NPROC limit
In-Reply-To:
References:
Message-ID: <4D9B3500.4080302@redhat.com>
On 04/05/2011 08:09 AM, Jiri Denemark wrote:
> This patch adds max_processes option to qemu.conf which can be used to
> override system default limit on number of processes that are allowed to
> be running for qemu user.
> ---
> src/qemu/libvirtd_qemu.aug | 3 +++
> src/qemu/qemu.conf | 7 +++++++
> src/qemu/qemu_conf.c | 4 ++++
> src/qemu/qemu_conf.h | 2 ++
> src/qemu/qemu_process.c | 24 ++++++++++++++++++++++++
> src/qemu/test_libvirtd_qemu.aug | 4 ++++
> 6 files changed, 44 insertions(+), 0 deletions(-)
> @@ -1821,6 +1842,9 @@ static int qemuProcessHook(void *data)
> {
> struct qemuProcessHookData *h = data;
>
> + if (qemuProcessLimits(h->driver) < 0)
> + return -1;
Which UID is in effect at this point? While setrlimit() adjusts an
inherited value, I'm a bit worried that tracks different limits per uid,
and if the call is made while the real uid is root instead of qemu, then
we might be affecting the wrong limit. Does this call need to be
delayed until after the virSecurityManagerSetProcessLabel, or after we
are sure that we have changed identities?
But other than that question, the code looks sane, and I appreciate
seeing the augeas modifications, too.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL:
From minovotn at redhat.com Tue Apr 5 15:28:58 2011
From: minovotn at redhat.com (Michal Novotny)
Date: Tue, 05 Apr 2011 17:28:58 +0200
Subject: [libvirt] Using Restore in another host.
In-Reply-To:
References: