[libvirt] [PATCH] build: consistently use CFLAGS
by Eric Blake
According to the automake manual, CPPFLAGS (aka INCLUDES, as spelled
in automake 1.9.6) should only include -I, -D, and -U directives; more
generic directives like -Wall belong in CFLAGS since they affect more
phases of the build process. Therefore, we should be sticking CFLAGS
additions into a CFLAGS container, not a CPPFLAGS container.
* src/Makefile.am (INCLUDES): Move CFLAGS items...
(AM_CFLAGS): ...to their proper location.
* python/Makefile.am (INCLUDES, AM_CFLAGS): Likewise.
* tests/Makefile.am (INCLUDES, AM_CFLAGS): Likewise.
---
python/Makefile.am | 5 +++--
src/Makefile.am | 15 +++++++--------
tests/Makefile.am | 8 +++++---
3 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/python/Makefile.am b/python/Makefile.am
index 432ad70..0edb3e4 100644
--- a/python/Makefile.am
+++ b/python/Makefile.am
@@ -3,12 +3,13 @@
SUBDIRS= . tests
INCLUDES = \
- $(WARN_CFLAGS) \
- $(PYTHON_INCLUDES) \
+ $(PYTHON_INCLUDES) \
-I$(top_srcdir)/include \
-I$(top_builddir)/include \
-I$(top_builddir)/$(subdir)
+AM_CFLAGS = $(WARN_CFLAGS)
+
DOCS_DIR = $(datadir)/doc/libvirt-python-$(LIBVIRT_VERSION)
DOCS = ${srcdir}/TODO
diff --git a/src/Makefile.am b/src/Makefile.am
index 02d53ee..292fa30 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -3,20 +3,19 @@
# No libraries with the exception of LIBXML should be listed
# here. List them against the individual XXX_la_CFLAGS targets
# that actually use them
-INCLUDES = \
- -I$(top_srcdir)/gnulib/lib \
+INCLUDES = -I$(top_srcdir)/gnulib/lib \
-I../gnulib/lib \
-I../include \
-I@top_srcdir@/src/util \
-I@top_srcdir@/include \
- $(DRIVER_MODULE_CFLAGS) \
+ -DIN_LIBVIRT
+
+AM_CFLAGS = $(DRIVER_MODULE_CFLAGS) \
$(LIBXML_CFLAGS) \
$(WARN_CFLAGS) \
- $(LOCK_CHECKING_CFLAGS) \
- -DIN_LIBVIRT \
- $(WIN32_EXTRA_CFLAGS)
-
-AM_CFLAGS = $(COVERAGE_CFLAGS)
+ $(LOCK_CHECKING_CFLAGS) \
+ $(WIN32_EXTRA_CFLAGS) \
+ $(COVERAGE_CFLAGS)
AM_LDFLAGS = $(COVERAGE_LDFLAGS)
EXTRA_DIST = $(conf_DATA)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 7ae50a2..2b21d82 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -8,14 +8,16 @@ INCLUDES = \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/util \
- -I$(top_srcdir)/src/conf \
+ -I$(top_srcdir)/src/conf
+
+AM_CFLAGS = \
$(LIBXML_CFLAGS) \
$(GNUTLS_CFLAGS) \
$(SASL_CFLAGS) \
$(SELINUX_CFLAGS) \
$(APPARMOR_CFLAGS) \
- $(COVERAGE_CFLAGS) \
- $(WARN_CFLAGS)
+ $(COVERAGE_CFLAGS) \
+ $(WARN_CFLAGS)
if WITH_DRIVER_MODULES
INCLUDES += \
--
1.7.4.4
13 years, 5 months
[libvirt] [PATCH] graphics: add support for action_if_connected in qemu
by Michal Privoznik
This option accepts 3 values:
-keep, to keep current client connected (Spice+VNC)
-disconnect, to disconnect client (Spice)
-fail, to fail setting password if there is a client connected (Spice)
---
docs/schemas/domain.rng | 16 ++++++++++++++++
src/conf/domain_conf.c | 44 +++++++++++++++++++++++++++++++++++++++++---
src/conf/domain_conf.h | 11 +++++++++++
src/libvirt_private.syms | 2 ++
src/qemu/qemu_hotplug.c | 11 ++++++++---
5 files changed, 78 insertions(+), 6 deletions(-)
diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index c270815..f0efe60 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -1227,6 +1227,13 @@
<data type="dateTime"/>
</attribute>
</optional>
+ <optional>
+ <attribute name="connected">
+ <choice>
+ <value>keep</value>
+ </choice>
+ </attribute>
+ </optional>
</group>
<group>
<attribute name="type">
@@ -1270,6 +1277,15 @@
<data type="dateTime"/>
</attribute>
</optional>
+ <optional>
+ <attribute name="connected">
+ <choice>
+ <value>fail</value>
+ <value>disconnect</value>
+ <value>keep</value>
+ </choice>
+ </attribute>
+ </optional>
<interleave>
<zeroOrMore>
<element name="channel">
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index fbef61e..571fcf4 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -313,6 +313,13 @@ VIR_ENUM_IMPL(virDomainGraphics, VIR_DOMAIN_GRAPHICS_TYPE_LAST,
"desktop",
"spice")
+VIR_ENUM_IMPL(virDomainGraphicsAuthConnected,
+ VIR_DOMAIN_GRAPHICS_AUTH_CONNECTED_LAST,
+ "default",
+ "fail",
+ "disconnect",
+ "keep")
+
VIR_ENUM_IMPL(virDomainGraphicsSpiceChannelName,
VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST,
"main",
@@ -3803,9 +3810,12 @@ error:
static int
-virDomainGraphicsAuthDefParseXML(xmlNodePtr node, virDomainGraphicsAuthDefPtr def)
+virDomainGraphicsAuthDefParseXML(xmlNodePtr node,
+ virDomainGraphicsAuthDefPtr def,
+ int type)
{
char *validTo = NULL;
+ char *connected = virXMLPropString(node, "connected");
def->passwd = virXMLPropString(node, "passwd");
@@ -3846,6 +3856,28 @@ virDomainGraphicsAuthDefParseXML(xmlNodePtr node, virDomainGraphicsAuthDefPtr de
def->expires = 1;
}
+ if (connected) {
+ int action = virDomainGraphicsAuthConnectedTypeFromString(connected);
+ if (action < 0) {
+ virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown connected value %s"),
+ connected);
+ VIR_FREE(connected);
+ return -1;
+ }
+ VIR_FREE(connected);
+
+ /* VNC supports connected='keep' only */
+ if (type == VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
+ action != VIR_DOMAIN_GRAPHICS_AUTH_CONNECTED_KEEP) {
+ virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("VNC supports connected='keep' only"));
+ return -1;
+ }
+
+ def->connected = action;
+ }
+
return 0;
}
@@ -3915,7 +3947,8 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, int flags) {
!def->data.vnc.listenAddr[0])
VIR_FREE(def->data.vnc.listenAddr);
- if (virDomainGraphicsAuthDefParseXML(node, &def->data.vnc.auth) < 0)
+ if (virDomainGraphicsAuthDefParseXML(node, &def->data.vnc.auth,
+ def->type) < 0)
goto error;
} else if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_SDL) {
char *fullscreen = virXMLPropString(node, "fullscreen");
@@ -4051,7 +4084,8 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, int flags) {
!def->data.spice.listenAddr[0])
VIR_FREE(def->data.spice.listenAddr);
- if (virDomainGraphicsAuthDefParseXML(node, &def->data.spice.auth) < 0)
+ if (virDomainGraphicsAuthDefParseXML(node, &def->data.spice.auth,
+ def->type) < 0)
goto error;
cur = node->children;
@@ -7995,6 +8029,10 @@ virDomainGraphicsAuthDefFormatAttr(virBufferPtr buf,
strftime(strbuf, sizeof(strbuf), "%Y-%m-%dT%H:%M:%S", tm);
virBufferAsprintf(buf, " passwdValidTo='%s'", strbuf);
}
+
+ if (def->connected)
+ virBufferEscapeString(buf, " connected='%s'",
+ virDomainGraphicsAuthConnectedTypeToString(def->connected));
}
static int
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 8c94d4d..d090b9a 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -631,12 +631,22 @@ enum virDomainGraphicsType {
VIR_DOMAIN_GRAPHICS_TYPE_LAST,
};
+enum virDomainGraphicsAuthConnectedType {
+ VIR_DOMAIN_GRAPHICS_AUTH_CONNECTED_DEFAULT = 0,
+ VIR_DOMAIN_GRAPHICS_AUTH_CONNECTED_FAIL,
+ VIR_DOMAIN_GRAPHICS_AUTH_CONNECTED_DISCONNECT,
+ VIR_DOMAIN_GRAPHICS_AUTH_CONNECTED_KEEP,
+
+ VIR_DOMAIN_GRAPHICS_AUTH_CONNECTED_LAST
+};
+
typedef struct _virDomainGraphicsAuthDef virDomainGraphicsAuthDef;
typedef virDomainGraphicsAuthDef *virDomainGraphicsAuthDefPtr;
struct _virDomainGraphicsAuthDef {
char *passwd;
unsigned int expires: 1; /* Whether there is an expiry time set */
time_t validTo; /* seconds since epoch */
+ int connected; /* action if connected */
};
enum virDomainGraphicsSpiceChannelName {
@@ -1514,6 +1524,7 @@ VIR_ENUM_DECL(virDomainHostdevSubsys)
VIR_ENUM_DECL(virDomainInput)
VIR_ENUM_DECL(virDomainInputBus)
VIR_ENUM_DECL(virDomainGraphics)
+VIR_ENUM_DECL(virDomainGraphicsAuthConnected)
VIR_ENUM_DECL(virDomainGraphicsSpiceChannelName)
VIR_ENUM_DECL(virDomainGraphicsSpiceChannelMode)
VIR_ENUM_DECL(virDomainGraphicsSpiceImageCompression)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 321df2a..bb331a3 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -263,6 +263,8 @@ virDomainFindByID;
virDomainFindByName;
virDomainFindByUUID;
virDomainGetRootFilesystem;
+virDomainGraphicsAuthConnectedTypeFromString;
+virDomainGraphicsAuthConnectedTypeToString;
virDomainGraphicsDefFree;
virDomainGraphicsSpiceChannelModeTypeFromString;
virDomainGraphicsSpiceChannelModeTypeToString;
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 3cf7d35..c0c4a15 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1017,10 +1017,12 @@ qemuDomainChangeGraphics(struct qemud_driver *driver,
return -1;
}
- /* If a password lifetime was, or is set, then we must always run,
- * even if new password matches old password */
+ /* If a password lifetime was, or is set, or action if connected has
+ * changed, then we must always run, even if new password matches
+ * old password */
if (olddev->data.vnc.auth.expires ||
dev->data.vnc.auth.expires ||
+ olddev->data.vnc.auth.connected != dev->data.vnc.auth.connected ||
STRNEQ_NULLABLE(olddev->data.vnc.auth.passwd, dev->data.vnc.auth.passwd)) {
VIR_DEBUG("Updating password on VNC server %p %p", dev->data.vnc.auth.passwd, driver->vncPassword);
ret = qemuDomainChangeGraphicsPasswords(driver, vm, VIR_DOMAIN_GRAPHICS_TYPE_VNC,
@@ -1032,6 +1034,7 @@ qemuDomainChangeGraphics(struct qemud_driver *driver,
dev->data.vnc.auth.passwd = NULL;
olddev->data.vnc.auth.validTo = dev->data.vnc.auth.validTo;
olddev->data.vnc.auth.expires = dev->data.vnc.auth.expires;
+ olddev->data.vnc.auth.connected = dev->data.vnc.auth.connected;
} else {
ret = 0;
}
@@ -1060,6 +1063,7 @@ qemuDomainChangeGraphics(struct qemud_driver *driver,
* even if new password matches old password */
if (olddev->data.spice.auth.expires ||
dev->data.spice.auth.expires ||
+ olddev->data.spice.auth.connected != dev->data.spice.auth.connected ||
STRNEQ_NULLABLE(olddev->data.spice.auth.passwd, dev->data.spice.auth.passwd)) {
VIR_DEBUG("Updating password on SPICE server %p %p", dev->data.spice.auth.passwd, driver->spicePassword);
ret = qemuDomainChangeGraphicsPasswords(driver, vm, VIR_DOMAIN_GRAPHICS_TYPE_SPICE,
@@ -1071,6 +1075,7 @@ qemuDomainChangeGraphics(struct qemud_driver *driver,
dev->data.spice.auth.passwd = NULL;
olddev->data.spice.auth.validTo = dev->data.spice.auth.validTo;
olddev->data.spice.auth.expires = dev->data.spice.auth.expires;
+ olddev->data.spice.auth.connected = dev->data.spice.auth.connected;
} else {
VIR_DEBUG("Not updating since password didn't change");
ret = 0;
@@ -1755,7 +1760,7 @@ qemuDomainChangeGraphicsPasswords(struct qemud_driver *driver,
ret = qemuMonitorSetPassword(priv->mon,
type,
auth->passwd ? auth->passwd : defaultPasswd,
- NULL);
+ auth->connected ? virDomainGraphicsAuthConnectedTypeToString(auth->connected) : NULL);
if (ret == -2) {
if (type != VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
--
1.7.5.rc3
13 years, 5 months
[libvirt] [PATCH] maint: use consistent file name for threading notes
by Eric Blake
* daemon/THREADING.txt: Rename...
* daemon/THREADS.txt: ...to match qemu thread notes.
* daemon/Makefile.am (EXTRA_DIST): Reflect rename.
---
First suggested here:
https://www.redhat.com/archives/libvir-list/2011-May/msg01730.html
daemon/Makefile.am | 2 +-
daemon/{THREADING.txt => THREADS.txt} | 0
2 files changed, 1 insertions(+), 1 deletions(-)
rename daemon/{THREADING.txt => THREADS.txt} (100%)
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 92d154f..c1b4a9f 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -44,7 +44,7 @@ EXTRA_DIST = \
libvirtd.lxc.logrotate.in \
libvirtd.uml.logrotate.in \
test_libvirtd.aug \
- THREADING.txt \
+ THREADS.txt \
libvirtd.pod.in \
libvirtd.8.in \
libvirtd.stp \
diff --git a/daemon/THREADING.txt b/daemon/THREADS.txt
similarity index 100%
rename from daemon/THREADING.txt
rename to daemon/THREADS.txt
--
1.7.4.4
13 years, 5 months
[libvirt] [PATCHv2 0/8] add virGetSchedulerParamterFlags
by Eric Blake
V2 of this original series:
https://www.redhat.com/archives/libvir-list/2011-May/msg01142.html
Changes in this version:
rebase to latest
avoid regression in virTypedParameter consolidation
write new API in terms of virTypedParameter instead of virSchedParameter
Eric Blake (8):
libvirt.h: avoid regression, and document preferred name
maint: prefer newer API names internally
remote: consolidate typed parameter handling
sched: introduce virDomainGetSchedulerParametersFlags
qemu: introduce qemuGetSchedulerParametersFlags
remote: introduce remoteGetSchedulerParametersFlags
virsh: improve schedinfo querying ability
sched: provide new API shims for remaining drivers
daemon/remote.c | 563 +++++++++++++++++-------------------------
include/libvirt/libvirt.h.in | 275 +++++++++++----------
python/generator.py | 1 +
python/libvirt-override.c | 28 +-
src/driver.h | 22 ++-
src/esx/esx_driver.c | 60 +++--
src/libvirt.c | 96 ++++++-
src/libvirt_public.syms | 1 +
src/libxl/libxl_driver.c | 42 +++-
src/lxc/lxc_driver.c | 60 ++++--
src/qemu/qemu_driver.c | 115 +++++++---
src/remote/remote_driver.c | 525 ++++++++++++++++-----------------------
src/remote/remote_protocol.x | 87 +++-----
src/remote_protocol-structs | 63 ++---
src/test/test_driver.c | 41 +++-
src/xen/xen_driver.c | 36 +++-
src/xen/xen_hypervisor.c | 14 +-
src/xen/xen_hypervisor.h | 6 +-
src/xen/xend_internal.c | 12 +-
tools/virsh.c | 102 +++++---
20 files changed, 1102 insertions(+), 1047 deletions(-)
--
1.7.4.4
13 years, 5 months
Re: [libvirt] ssh from host to guest on default network
by Neil Wilson
> Message: 1
> Date: Mon, 30 May 2011 20:28:42 -0700
> From: Kay Williams <Kay(a)thewilliams.net>
> To: "libvir-list(a)redhat.com" <libvir-list(a)redhat.com>
> Subject: [libvirt] ssh from host to guest on default network
> Message-ID:
> <3527434A537F2F42A53BAA31DC03BB6A4A52040D70(a)SERVER1.family.local>
> Content-Type: text/plain; charset="us-ascii"
>
> Hello,
>
> The trouble I am having is with ssh'ing from the host to guest machine.
Probably more for the user list than this one. However...
I've used 'avahi' successfully to get resolution in the clients. It
implements the 'Bonjour' no configuration system. Obviously the client
image has to have the avahi daemons installed and correctly configured.
Once you have that working in the client and the correct settings in
your resolver on the host, then you can ssh into 'xyz.local' and it
resolves nicely.
Rgs
Neil
13 years, 5 months
[libvirt] [PATCH] openvz: Restore original EOF handling in openvzGetProcessInfo
by Matthias Bolte
This function is also affected by getline conversion. But this
didn't result in a regression in general, because the difference
whould only affect the behavior of the function when the line in
/proc/vz/vestat for the given vpsid wasn't found. Under normal
conditions this should not happen.
---
src/openvz/openvz_driver.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index ae951a2..e24b5d8 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -1507,6 +1507,7 @@ static int openvzGetProcessInfo(unsigned long long *cpuTime, int vpsid)
unsigned long long usertime, systime, nicetime;
int readvps = vpsid + 1; /* ensure readvps is initially different */
ssize_t ret;
+ int err = 0;
/* read statistic from /proc/vz/vestat.
sample:
@@ -1522,8 +1523,10 @@ Version: 2.2
/*search line with VEID=vpsid*/
while (1) {
ret = getline(&line, &line_size, fp);
- if (ret <= 0)
+ if (ret < 0) {
+ err = !feof(fp);
break;
+ }
if (sscanf (line, "%d %llu %llu %llu",
&readvps, &usertime, &nicetime, &systime) == 4
@@ -1538,7 +1541,7 @@ Version: 2.2
VIR_FREE(line);
VIR_FORCE_FCLOSE(fp);
- if (ret < 0)
+ if (err)
return -1;
if (readvps != vpsid) /*not found*/
--
1.7.0.4
13 years, 5 months
[libvirt] [PATCH v2] tests: Add more complex domain scheme test data
by Michal Privoznik
---
diff to v1:
-move from tests/domainschemadata/ to tests/qemuxml2argvdata/
-add .args
.../qemuxml2argv-graphics-spice-timeout.args | 14 +++
.../qemuxml2argv-graphics-spice-timeout.xml | 86 ++++++++++++++++++++
tests/qemuxml2argvtest.c | 5 +
tests/qemuxml2xmltest.c | 3 +-
4 files changed, 107 insertions(+), 1 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.xml
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.args
new file mode 100644
index 0000000..7c30e43
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.args
@@ -0,0 +1,14 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=spice \
+/usr/bin/qemu-kvm -S -M pc-0.13 -cpu core2duo,+lahf_lm,+xtpr,+cx16,+tm2,+est,+vmx,+ds_cpl,+pbe,+tm,+ht,+ss,+acpi,+ds \
+-m 1024 -smp 2 -nodefaults -monitor unix:/tmp/test-monitor,server,nowait \
+-boot dc -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x6 \
+-drive file=/var/lib/libvirt/images/f14.img,if=none,id=drive-virtio-disk0 \
+-device virtio-blk-pci,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0 \
+-drive file=/var/lib/libvirt/Fedora-14-x86_64-Live-KDE.iso,if=none,media=cdrom,id=drive-ide0-1-0 \
+-device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \
+-device rtl8139,vlan=0,id=net0,mac=52:54:00:71:70:89,bus=pci.0,addr=0x7 \
+-net tap,script=/etc/qemu-ifup,vlan=0,name=hostnet0 -serial pty \
+-usb -device usb-tablet,id=input0 \
+-spice port=5900,tls-port=0,x509-dir=/etc/pki/libvirt-spice -vga std \
+-device AC97,id=sound0,bus=pci.0,addr=0x3 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.xml
new file mode 100644
index 0000000..aaa4469
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.xml
@@ -0,0 +1,86 @@
+<domain type='qemu'>
+ <name>f14</name>
+ <uuid>553effab-b5e1-2d80-dfe3-da4344826c43</uuid>
+ <memory>1048576</memory>
+ <currentMemory>1048576</currentMemory>
+ <vcpu>2</vcpu>
+ <os>
+ <type arch='x86_64' machine='pc-0.13'>hvm</type>
+ <boot dev='cdrom'/>
+ <boot dev='hd'/>
+ <bootmenu enable='yes'/>
+ </os>
+ <features>
+ <acpi/>
+ <apic/>
+ <pae/>
+ </features>
+ <cpu match='exact'>
+ <model>core2duo</model>
+ <vendor>Intel</vendor>
+ <topology sockets='1' cores='2' threads='1'/>
+ <feature policy='require' name='lahf_lm'/>
+ <feature policy='require' name='xtpr'/>
+ <feature policy='require' name='cx16'/>
+ <feature policy='require' name='tm2'/>
+ <feature policy='require' name='est'/>
+ <feature policy='require' name='vmx'/>
+ <feature policy='require' name='ds_cpl'/>
+ <feature policy='require' name='pbe'/>
+ <feature policy='require' name='tm'/>
+ <feature policy='require' name='ht'/>
+ <feature policy='require' name='ss'/>
+ <feature policy='require' name='acpi'/>
+ <feature policy='require' name='ds'/>
+ </cpu>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>restart</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-kvm</emulator>
+ <disk type='file' device='disk'>
+ <driver name='qemu' type='qcow2'/>
+ <source file='/var/lib/libvirt/images/f14.img'/>
+ <target dev='vda' bus='virtio'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+ </disk>
+ <disk type='file' device='cdrom'>
+ <driver name='qemu' type='raw'/>
+ <source file='/var/lib/libvirt/Fedora-14-x86_64-Live-KDE.iso'/>
+ <target dev='hdc' bus='ide'/>
+ <readonly/>
+ <address type='drive' controller='0' bus='1' unit='0'/>
+ </disk>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+ </controller>
+ <controller type='virtio-serial' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
+ </controller>
+ <interface type='ethernet'>
+ <mac address='52:54:00:71:70:89'/>
+ <script path='/etc/qemu-ifup'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
+ </interface>
+ <serial type='pty'>
+ <target port='0'/>
+ </serial>
+ <console type='pty'>
+ <target type='serial' port='0'/>
+ </console>
+ <input type='tablet' bus='usb'/>
+ <input type='mouse' bus='ps2'/>
+ <graphics type='spice' port='5900' autoport='no' passwd='sercet' passwdValidTo='2011-05-31T16:11:22'/>
+ <sound model='ac97'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </sound>
+ <video>
+ <model type='vga' vram='9216' heads='1'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+ </video>
+ <memballoon model='virtio'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
+ </memballoon>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 33cc58f..c9076e1 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -357,6 +357,11 @@ mymain(void)
DO_TEST("graphics-spice-compression", false,
QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL,
QEMU_CAPS_DEVICE, QEMU_CAPS_SPICE);
+ DO_TEST("graphics-spice-timeout", false,
+ QEMU_CAPS_DRIVE,
+ QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL,
+ QEMU_CAPS_DEVICE, QEMU_CAPS_SPICE,
+ QEMU_CAPS_DEVICE_QXL_VGA);
DO_TEST("graphics-spice-qxl-vga", false,
QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL,
QEMU_CAPS_DEVICE, QEMU_CAPS_SPICE,
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 1574cae..64a833f 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -35,7 +35,7 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml)
VIR_DOMAIN_XML_INACTIVE)))
goto fail;
- if (!(actual = virDomainDefFormat(def, 0)))
+ if (!(actual = virDomainDefFormat(def, VIR_DOMAIN_XML_SECURE)))
goto fail;
@@ -144,6 +144,7 @@ mymain(void)
DO_TEST("graphics-sdl-fullscreen");
DO_TEST("graphics-spice");
DO_TEST("graphics-spice-compression");
+ DO_TEST("graphics-spice-timeout");
DO_TEST("graphics-spice-qxl-vga");
DO_TEST("input-usbmouse");
DO_TEST("input-usbtablet");
--
1.7.5.rc3
13 years, 5 months
[libvirt] [PATCH] openvz: Handle getline failures in openvzReadConfigParam properly
by Matthias Bolte
The regression fix in 3aab7f2d6b068f0 altered the error handling.
getline returns -1 on failure to read a line (including EOF). The
original openvzReadConfigParam function using openvz_readline only
treated EOF as not-found. The current getline version treats all
getline failures as not-found.
This patch fixes this and distinguished EOF from other getline
failures.
---
src/openvz/openvz_conf.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c
index 2cccd81..bf6ee2c 100644
--- a/src/openvz/openvz_conf.c
+++ b/src/openvz/openvz_conf.c
@@ -659,7 +659,12 @@ openvzReadConfigParam(const char *conf_file, const char *param, char **value)
return -1;
VIR_FREE(*value);
- while (getline(&line, &line_size, fp) >= 0) {
+ while (1) {
+ if (getline(&line, &line_size, fp) < 0) {
+ err = !feof(fp);
+ break;
+ }
+
if (! STREQLEN(line, param, strlen(param)))
continue;
--
1.7.0.4
13 years, 5 months
[libvirt] [PATCH] * .gitignore: Exempt a new test binary.
by Eric Blake
---
Pushing under the trivial rule.
.gitignore | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
index a15100c..a4d3ea1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -57,6 +57,7 @@
/tests/cputest
/tests/hashtest
/tests/nwfilterxml2xmltest
+/tests/openvzutilstest
/update.log
Makefile
Makefile.in
--
1.7.4.4
13 years, 5 months
[libvirt] [PATCH v4] storage: List directory volumes for dir/fs/netfs pools
by Cole Robinson
Since directories can be used for <filesystem> passthrough, they are
basically storage volumes.
v2:
Skip ., .., lost+found dirs
v3:
Use gnulib last_component
v4:
Use gnulib "dirname.h", not system <dirname.h>
Don't skip lost+found
Signed-off-by: Cole Robinson <crobinso(a)redhat.com>
---
src/storage/storage_backend.c | 44 +++++++++++++++++++++++++++++++------
src/storage/storage_backend.h | 7 +++++-
src/storage/storage_backend_fs.c | 14 ++++++++---
src/util/storage_file.c | 30 +++++++++++++++++++++++++-
4 files changed, 82 insertions(+), 13 deletions(-)
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 02e455f..d269e4c 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -36,6 +36,7 @@
#include <sys/stat.h>
#include <sys/param.h>
#include <dirent.h>
+#include "dirname.h"
#ifdef __linux__
# include <sys/ioctl.h>
# include <linux/fs.h>
@@ -994,6 +995,7 @@ virStorageBackendVolOpenCheckMode(const char *path, unsigned int flags)
{
int fd, mode = 0;
struct stat sb;
+ char *base = last_component(path);
if ((fd = open(path, O_RDONLY|O_NONBLOCK|O_NOCTTY)) < 0) {
if ((errno == ENOENT || errno == ELOOP) &&
@@ -1022,9 +1024,20 @@ virStorageBackendVolOpenCheckMode(const char *path, unsigned int flags)
mode = VIR_STORAGE_VOL_OPEN_CHAR;
else if (S_ISBLK(sb.st_mode))
mode = VIR_STORAGE_VOL_OPEN_BLOCK;
+ else if (S_ISDIR(sb.st_mode)) {
+ mode = VIR_STORAGE_VOL_OPEN_DIR;
+
+ if (STREQ(base, ".") ||
+ STREQ(base, "..")) {
+ VIR_FORCE_CLOSE(fd);
+ VIR_INFO("Skipping special dir '%s'", base);
+ return -2;
+ }
+ }
if (!(mode & flags)) {
VIR_FORCE_CLOSE(fd);
+ VIR_INFO("Skipping volume '%s'", path);
if (mode & VIR_STORAGE_VOL_OPEN_ERROR) {
virStorageReportError(VIR_ERR_INTERNAL_ERROR,
@@ -1047,11 +1060,13 @@ int virStorageBackendVolOpen(const char *path)
int
virStorageBackendUpdateVolTargetInfo(virStorageVolTargetPtr target,
unsigned long long *allocation,
- unsigned long long *capacity)
+ unsigned long long *capacity,
+ unsigned int openflags)
{
int ret, fd;
- if ((ret = virStorageBackendVolOpen(target->path)) < 0)
+ if ((ret = virStorageBackendVolOpenCheckMode(target->path,
+ openflags)) < 0)
return ret;
fd = ret;
@@ -1066,24 +1081,34 @@ virStorageBackendUpdateVolTargetInfo(virStorageVolTargetPtr target,
}
int
-virStorageBackendUpdateVolInfo(virStorageVolDefPtr vol,
- int withCapacity)
+virStorageBackendUpdateVolInfoFlags(virStorageVolDefPtr vol,
+ int withCapacity,
+ unsigned int openflags)
{
int ret;
if ((ret = virStorageBackendUpdateVolTargetInfo(&vol->target,
- &vol->allocation,
- withCapacity ? &vol->capacity : NULL)) < 0)
+ &vol->allocation,
+ withCapacity ? &vol->capacity : NULL,
+ openflags)) < 0)
return ret;
if (vol->backingStore.path &&
(ret = virStorageBackendUpdateVolTargetInfo(&vol->backingStore,
- NULL, NULL)) < 0)
+ NULL, NULL,
+ VIR_STORAGE_VOL_OPEN_DEFAULT)) < 0)
return ret;
return 0;
}
+int virStorageBackendUpdateVolInfo(virStorageVolDefPtr vol,
+ int withCapacity)
+{
+ return virStorageBackendUpdateVolInfoFlags(vol, withCapacity,
+ VIR_STORAGE_VOL_OPEN_DEFAULT);
+}
+
/*
* virStorageBackendUpdateVolTargetInfoFD:
* @conn: connection to report errors on
@@ -1125,6 +1150,11 @@ virStorageBackendUpdateVolTargetInfoFD(virStorageVolTargetPtr target,
*/
if (capacity)
*capacity = sb.st_size;
+ } else if (S_ISDIR(sb.st_mode)) {
+ *allocation = 0;
+ if (capacity)
+ *capacity = 0;
+
} else {
off_t end;
/* XXX this is POSIX compliant, but doesn't work for CHAR files,
diff --git a/src/storage/storage_backend.h b/src/storage/storage_backend.h
index fcfbed0..67ac32c 100644
--- a/src/storage/storage_backend.h
+++ b/src/storage/storage_backend.h
@@ -93,6 +93,7 @@ enum {
VIR_STORAGE_VOL_OPEN_REG = 1 << 1, /* regular files okay */
VIR_STORAGE_VOL_OPEN_BLOCK = 1 << 2, /* block files okay */
VIR_STORAGE_VOL_OPEN_CHAR = 1 << 3, /* char files okay */
+ VIR_STORAGE_VOL_OPEN_DIR = 1 << 4, /* directories okay */
};
# define VIR_STORAGE_VOL_OPEN_DEFAULT (VIR_STORAGE_VOL_OPEN_ERROR |\
@@ -107,9 +108,13 @@ ATTRIBUTE_NONNULL(1);
int virStorageBackendUpdateVolInfo(virStorageVolDefPtr vol,
int withCapacity);
+int virStorageBackendUpdateVolInfoFlags(virStorageVolDefPtr vol,
+ int withCapacity,
+ unsigned int openflags);
int virStorageBackendUpdateVolTargetInfo(virStorageVolTargetPtr target,
unsigned long long *allocation,
- unsigned long long *capacity);
+ unsigned long long *capacity,
+ unsigned int openflags);
int virStorageBackendUpdateVolTargetInfoFD(virStorageVolTargetPtr target,
int fd,
unsigned long long *allocation,
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index b8d4d63..3f4d978 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -48,6 +48,11 @@
#define VIR_FROM_THIS VIR_FROM_STORAGE
+#define VIR_STORAGE_VOL_FS_OPEN_FLAGS (VIR_STORAGE_VOL_OPEN_DEFAULT |\
+ VIR_STORAGE_VOL_OPEN_DIR)
+#define VIR_STORAGE_VOL_FS_REFRESH_FLAGS (VIR_STORAGE_VOL_FS_OPEN_FLAGS &\
+ ~VIR_STORAGE_VOL_OPEN_ERROR)
+
static int ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
virStorageBackendProbeTarget(virStorageVolTargetPtr target,
char **backingStore,
@@ -65,7 +70,7 @@ virStorageBackendProbeTarget(virStorageVolTargetPtr target,
*encryption = NULL;
if ((ret = virStorageBackendVolOpenCheckMode(target->path,
- (VIR_STORAGE_VOL_OPEN_DEFAULT & ~VIR_STORAGE_VOL_OPEN_ERROR))) < 0)
+ VIR_STORAGE_VOL_FS_REFRESH_FLAGS)) < 0)
return ret; /* Take care to propagate ret, it is not always -1 */
fd = ret;
@@ -676,8 +681,8 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn ATTRIBUTE_UNUSED,
vol->backingStore.format = backingStoreFormat;
if (virStorageBackendUpdateVolTargetInfo(&vol->backingStore,
- NULL,
- NULL) < 0) {
+ NULL, NULL,
+ VIR_STORAGE_VOL_OPEN_DEFAULT) < 0) {
/* The backing file is currently unavailable, the capacity,
* allocation, owner, group and mode are unknown. Just log the
* error an continue.
@@ -941,7 +946,8 @@ virStorageBackendFileSystemVolRefresh(virConnectPtr conn,
int ret;
/* Refresh allocation / permissions info in case its changed */
- ret = virStorageBackendUpdateVolInfo(vol, 0);
+ ret = virStorageBackendUpdateVolInfoFlags(vol, 0,
+ VIR_STORAGE_VOL_FS_OPEN_FLAGS);
if (ret < 0)
return ret;
diff --git a/src/util/storage_file.c b/src/util/storage_file.c
index ede79fa..8dbd933 100644
--- a/src/util/storage_file.c
+++ b/src/util/storage_file.c
@@ -24,6 +24,7 @@
#include <config.h>
#include "storage_file.h"
+#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#ifdef __linux__
@@ -736,6 +737,19 @@ virStorageFileProbeFormatFromFD(const char *path, int fd)
unsigned char *head;
ssize_t len = STORAGE_MAX_HEAD;
int ret = -1;
+ struct stat sb;
+
+ if (fstat(fd, &sb) < 0) {
+ virReportSystemError(errno,
+ _("cannot stat file '%s'"),
+ path);
+ return -1;
+ }
+
+ /* No header to probe for directories */
+ if (S_ISDIR(sb.st_mode)) {
+ return VIR_STORAGE_FILE_DIR;
+ }
if (VIR_ALLOC_N(head, len) < 0) {
virReportOOMError();
@@ -812,9 +826,10 @@ virStorageFileGetMetadataFromFD(const char *path,
int format,
virStorageFileMetadata *meta)
{
- unsigned char *head;
+ unsigned char *head = NULL;
ssize_t len = STORAGE_MAX_HEAD;
int ret = -1;
+ struct stat sb;
if (VIR_ALLOC_N(head, len) < 0) {
virReportOOMError();
@@ -823,6 +838,19 @@ virStorageFileGetMetadataFromFD(const char *path,
memset(meta, 0, sizeof (*meta));
+ if (fstat(fd, &sb) < 0) {
+ virReportSystemError(errno,
+ _("cannot stat file '%s'"),
+ path);
+ return -1;
+ }
+
+ /* No header to probe for directories */
+ if (S_ISDIR(sb.st_mode)) {
+ ret = 0;
+ goto cleanup;
+ }
+
if (lseek(fd, 0, SEEK_SET) == (off_t)-1) {
virReportSystemError(errno, _("cannot seek to start of '%s'"), path);
goto cleanup;
--
1.7.4.4
13 years, 5 months