[libvirt] [PATCH 0/7] lxc: Improve container startup error reporting
by Cole Robinson
Currently most LXC container startup failures result in a reported
success followed immediately by a guest shutoff.
This patch series tries to improve the situation by adding a basic
handshake from driver<->controller and controller<->container. If
the handshake fails, the driver will return the output from the
guest logfile, similar to how we do for qemu guests.
A few additional error reporting improvements are also included.
Cole Robinson (7):
lxc: Drop container stdio as late as possible
lxc: Don't report error in Wait/SendContinue
lxc: Refactor controller command building
lxc: Improve guest startup error reporting
lxc: controller: Improve container error reporting
lxc: Verify root fs exists before mounting
lxc: Ensure container <init> actually exists
src/lxc/lxc_container.c | 67 +++++++++++-------
src/lxc/lxc_container.h | 2 +
src/lxc/lxc_controller.c | 63 ++++++++++++++++-
src/lxc/lxc_driver.c | 173 +++++++++++++++++++++++++++++++++++++---------
4 files changed, 243 insertions(+), 62 deletions(-)
--
1.7.4.4
13 years, 5 months
[libvirt] [PATCH 0/4 v3] More virCommand conversions and cleanups
by Cole Robinson
The following series converts the last user of virExec to use
virCommand. The remaining functionality is then moved out of
util.c and into command.c
v2:
Committed some patches
Dropped final patch, can be submitted seperately
Addressed Eric's comments
v3:
Commited some patches
Addressed Eric's v2 comments
Cole Robinson (4):
qemu: Convert virExec usage to virCommand
util: Remove unused virExec wrapper
util: Implement virRun as a wrapper around virCommand
Move virRun, virExec*, virFork to util/command
cfg.mk | 3 +-
src/libvirt_private.syms | 6 +-
src/lxc/veth.c | 2 +-
src/nwfilter/nwfilter_ebiptables_driver.c | 1 +
src/qemu/qemu_driver.c | 26 +-
src/qemu/qemu_process.c | 2 +-
src/storage/storage_backend_fs.c | 2 +-
src/storage/storage_backend_logical.c | 2 +-
src/util/command.c | 565 ++++++++++++++++++++++++-
src/util/command.h | 14 +
src/util/ebtables.c | 2 +-
src/util/pci.c | 2 +-
src/util/util.c | 661 +----------------------------
src/util/util.h | 32 --
src/vmware/vmware_driver.c | 1 +
15 files changed, 608 insertions(+), 713 deletions(-)
--
1.7.4.4
13 years, 5 months
[libvirt] [PATCH] Fix allocation of veth's to not skip an index
by Daniel P. Berrange
The algorithm for autoassigning vethXXX devices, was always
skipping over the starting dev index when finding a free
name for the guest device. This should only be done if the host
device was autoallocated.
* src/lxc/veth.c: Don't skip over veth indexes
---
src/lxc/veth.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/lxc/veth.c b/src/lxc/veth.c
index a00aa23..22dbed5 100644
--- a/src/lxc/veth.c
+++ b/src/lxc/veth.c
@@ -46,6 +46,7 @@ static int getFreeVethName(char **veth, int startDev)
int devNum = startDev-1;
char *path = NULL;
+ VIR_DEBUG("Find free from veth%d", startDev);
do {
VIR_FREE(path);
++devNum;
@@ -53,6 +54,7 @@ static int getFreeVethName(char **veth, int startDev)
virReportOOMError();
return -1;
}
+ VIR_DEBUG("Probe %s", path);
} while (virFileExists(path));
VIR_FREE(path);
@@ -60,6 +62,7 @@ static int getFreeVethName(char **veth, int startDev)
virReportOOMError();
return -1;
}
+
return devNum;
}
@@ -98,18 +101,19 @@ int vethCreate(char** veth1, char** veth2)
bool veth1_alloc = false;
bool veth2_alloc = false;
- VIR_DEBUG("veth1: %s veth2: %s", NULLSTR(*veth1), NULLSTR(*veth2));
+ VIR_DEBUG("Host: %s guest: %s", NULLSTR(*veth1), NULLSTR(*veth2));
if (*veth1 == NULL) {
if ((vethDev = getFreeVethName(veth1, vethDev)) < 0)
goto cleanup;
- VIR_DEBUG("Assigned veth1: %s", *veth1);
+ VIR_DEBUG("Assigned host: %s", *veth1);
veth1_alloc = true;
+ vethDev++;
}
argv[3] = *veth1;
while (*veth2 == NULL) {
- if ((vethDev = getFreeVethName(veth2, vethDev + 1)) < 0) {
+ if ((vethDev = getFreeVethName(veth2, vethDev)) < 0) {
if (veth1_alloc)
VIR_FREE(*veth1);
goto cleanup;
@@ -122,12 +126,12 @@ int vethCreate(char** veth1, char** veth2)
continue;
}
- VIR_DEBUG("Assigned veth2: %s", *veth2);
+ VIR_DEBUG("Assigned guest: %s", *veth2);
veth2_alloc = true;
}
argv[8] = *veth2;
- VIR_DEBUG("veth1: %s veth2: %s", *veth1, *veth2);
+ VIR_DEBUG("Create Host: %s guest: %s", *veth1, *veth2);
if (virRun(argv, NULL) < 0) {
if (veth1_alloc)
VIR_FREE(*veth1);
--
1.7.4.4
13 years, 5 months
[libvirt] [PATCH] esx: Remove duplicated invalid-argument checks
by Matthias Bolte
Those checks are already performed at the public API level.
---
src/esx/esx_driver.c | 10 ----------
src/esx/esx_storage_driver.c | 5 -----
2 files changed, 0 insertions(+), 15 deletions(-)
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 500dc52..a5b96a9 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -1479,11 +1479,6 @@ esxListDomains(virConnectPtr conn, int *ids, int maxids)
esxVI_VirtualMachinePowerState powerState;
int count = 0;
- if (ids == NULL || maxids < 0) {
- ESX_ERROR(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument"));
- return -1;
- }
-
if (maxids == 0) {
return 0;
}
@@ -2895,11 +2890,6 @@ esxListDefinedDomains(virConnectPtr conn, char **const names, int maxnames)
int count = 0;
int i;
- if (names == NULL || maxnames < 0) {
- ESX_ERROR(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument"));
- return -1;
- }
-
if (maxnames == 0) {
return 0;
}
diff --git a/src/esx/esx_storage_driver.c b/src/esx/esx_storage_driver.c
index 6461917..c7fc992 100644
--- a/src/esx/esx_storage_driver.c
+++ b/src/esx/esx_storage_driver.c
@@ -167,11 +167,6 @@ esxListStoragePools(virConnectPtr conn, char **const names, int maxnames)
int count = 0;
int i;
- if (names == NULL || maxnames < 0) {
- ESX_ERROR(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument"));
- return -1;
- }
-
if (maxnames == 0) {
return 0;
}
--
1.7.0.4
13 years, 5 months
[libvirt] vcpupin: fix cpu affinity setting bug of qemu driver
by Taku Izumi
There is the case where cpu affinites for vcpu of qemu doesn't work
correctly.
For example, if only one vcpupin setting entry is provided and its setting
is
not for vcpu0, it doesn't work.
# virsh dumpxml VM
...
<vcpu>4</vcpu>
<cputune>
<vcpupin vcpu='3' cpuset='9-11'/>
</cputune>
...
# virsh start VM
Domain VM started
# virsh vcpuinfo VM
VCPU: 0
CPU: 31
State: running
CPU time: 2.5s
CPU Affinity: yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
VCPU: 1
CPU: 12
State: running
CPU time: 0.9s
CPU Affinity: yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
VCPU: 2
CPU: 30
State: running
CPU time: 1.5s
CPU Affinity: yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
VCPU: 3
CPU: 13
State: running
CPU time: 1.7s
CPU Affinity: yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
This patch fixes this problem.
Signed-off-by: Taku Izumi <izumi.taku(a)jp.fujitsu.com>
---
src/qemu/qemu_process.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
Index: libvirt/src/qemu/qemu_process.c
===================================================================
--- libvirt.orig/src/qemu/qemu_process.c
+++ libvirt/src/qemu/qemu_process.c
@@ -1194,7 +1194,7 @@ qemuProcessSetVcpuAffinites(virConnectPt
virNodeInfo nodeinfo;
pid_t vcpupid;
unsigned char *cpumask;
- int vcpu, cpumaplen, hostcpus, maxcpu;
+ int vcpu, cpumaplen, hostcpus, maxcpu, n;
unsigned char *cpumap = NULL;
int ret = -1;
@@ -1223,14 +1223,12 @@ qemuProcessSetVcpuAffinites(virConnectPt
return -1;
}
- for (vcpu = 0; vcpu < def->cputune.nvcpupin; vcpu++) {
- if (vcpu != def->cputune.vcpupin[vcpu]->vcpuid)
- continue;
-
+ for (n = 0; n < def->cputune.nvcpupin; n++) {
int i;
+ vcpu = def->cputune.vcpupin[n]->vcpuid;
memset(cpumap, 0, cpumaplen);
- cpumask = (unsigned char *)def->cputune.vcpupin[vcpu]->cpumask;
+ cpumask = (unsigned char *)def->cputune.vcpupin[n]->cpumask;
vcpupid = priv->vcpupids[vcpu];
/* Convert cpumask to bitmap here. */
13 years, 5 months
[libvirt] USB 2.0 support in qemu
by Gerd Hoffmann
Hi,
Recently USB 2.0 support was merged into upstream qemu, I guess libvirt
and virt-manager needs some bits to support this ...
The docs/usb2.txt file in the qemu source tree carries some information
on how to use it, and also some hints for USB pass-through. The most
recent version (not yet merged upstream) can be found here:
http://www.kraxel.org/cgit/qemu/tree/docs/usb2.txt?h=usb.15
If there are any questions feel free to ask.
cheers,
Gerd
13 years, 5 months
[libvirt] [PATCH] docs: Add doc for video element
by Osier Yang
For backwards compatability, if no <video> is set but there is a
<graphics> tag, then we add a default <video> according to the
guest type. Add docs to tell the user about this to not make
them confused. Especially if they remove the video (such as via
"virsh edit"), it will be surprised for them to see the video
element is still in domain XML.
---
docs/formatdomain.html.in | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index f8baffd..455f4dd 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1868,7 +1868,12 @@ qemu-kvm -net nic,model=? /dev/null
<dt><code>video</code></dt>
<dd>
The <code>video</code> element is the a container for describing
- video devices.
+ video devices. NB, for backwards compatability, if no <code>video</code>
+ is set but there is a <code>graphics</code> in domain xml, then libvirt
+ will add a default <code>video</code> according to the guest type, e.g.
+ For a guest of type "kvm", the default <code>video</code> for it is:
+ <code>type</code> with value "cirrus", <code>vram</code> with value "9216",
+ and <code>heads</code> with value "1".
</dd>
<dt><code>model</code></dt>
--
1.7.4
13 years, 5 months
[libvirt] [PATCH] Avoid virGetVersion failure on specific driver support configurations
by Matthias Bolte
virGetVersion itself doesn't take a virConnectPtr, but in order to obtain
the hypervisor version against which libvirt was compiled it is used in
combination with virConnectGetType like this:
hvType = virConnectGetType(conn)
virGetVersion(&libVer, hvType, &typeVer)
When virConnectGetType is called on a remote connection then the remote
driver returns the type of the underlying driver on the server side, for
example QEMU. Then virGetVersion compares hvType to a set of strings that
depend on configure options and returns LIBVIR_VERSION_NUMBER in most
cases. Now this fails in case libvirt on the client side is just compiled
with the remote driver enabled only and the server side has the actual
driver such as the QEMU driver. It just happens to work when the actual
driver is enabled on client and server side. But that's not always true.
I noticed this on FreeBSD:
freebsd# virsh -c qemu+tcp://192.168.178.22/system version
Compiled against library: libvir 0.9.2
error: failed to get the library version
error: this function is not supported by the connection driver: virGetVersion
This is not FreeBSD specific, happens on Windows as well due to the
similar driver support configuration. The problem is that virConnectGetType
returns QEMU, but virGetVersion on the client side only accepts Remote
as hvType due to all other drivers being disabled on the client side.
Daniel P. Berrange suggested to get rid of all the conditional code in
virGetVersion, ignoring the hvType and always setting typeVer to
LIBVIR_VERSION_NUMBER. virConnectGetVersion is supposed to be used to
obtain the hypervisor version.
---
src/libvirt.c | 86 ++++++--------------------------------------------------
1 files changed, 10 insertions(+), 76 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index cbe1926..5a96625 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -894,21 +894,24 @@ int virStateActive(void) {
/**
* virGetVersion:
* @libVer: return value for the library version (OUT)
- * @type: the type of connection/driver looked at, if @typeVer is not NULL
+ * @type: the type of the connection driver, ignored, just pass NULL
* @typeVer: optional return value for the version of the hypervisor (OUT)
*
* Provides information on up to two versions: @libVer is the version of the
* library and will always be set unless an error occurs, in which case an
- * error code will be returned. If @typeVer is not NULL it will be set to the
- * version of the hypervisor @type against which the library was compiled.
- * If @type is NULL, "Xen" is assumed, if @type is unknown or not
- * available, an error code will be returned and @typeVer will be 0.
+ * error code will be returned. If @typeVer is not NULL it should have been be
+ * set to the version of the hypervisor @type against which the library was
+ * compiled. Due to a design problem this doesn't work as intented. Therefore,
+ * this function is only usefull to obtain the local library version number via
+ * @libVer. To get the version of the running hypervisor use the
+ * virConnectGetVersion function instead. To get the libvirt library version
+ * used by a connection use the virConnectGetLibVersion instead.
*
* Returns -1 in case of failure, 0 otherwise, and values for @libVer and
* @typeVer have the format major * 1,000,000 + minor * 1,000 + release.
*/
int
-virGetVersion(unsigned long *libVer, const char *type,
+virGetVersion(unsigned long *libVer, const char *type ATTRIBUTE_UNUSED,
unsigned long *typeVer)
{
VIR_DEBUG("libVir=%p, type=%s, typeVer=%p", libVer, type, typeVer);
@@ -921,78 +924,9 @@ virGetVersion(unsigned long *libVer, const char *type,
goto error;
*libVer = LIBVIR_VERSION_NUMBER;
- if (typeVer != NULL) {
- if (type == NULL)
- type = "Xen";
-
-/* FIXME: Add _proper_ type version handling for loadable driver modules... */
-#ifdef WITH_DRIVER_MODULES
+ if (typeVer != NULL)
*typeVer = LIBVIR_VERSION_NUMBER;
-#else
- *typeVer = 0;
-# if WITH_XEN
- if (STRCASEEQ(type, "Xen"))
- *typeVer = xenUnifiedVersion();
-# endif
-# if WITH_TEST
- if (STRCASEEQ(type, "Test"))
- *typeVer = LIBVIR_VERSION_NUMBER;
-# endif
-# if WITH_QEMU
- if (STRCASEEQ(type, "QEMU"))
- *typeVer = LIBVIR_VERSION_NUMBER;
-# endif
-# if WITH_LXC
- if (STRCASEEQ(type, "LXC"))
- *typeVer = LIBVIR_VERSION_NUMBER;
-# endif
-# if WITH_LIBXL
- if (STRCASEEQ(type, "xenlight"))
- *typeVer = LIBVIR_VERSION_NUMBER;
-# endif
-# if WITH_PHYP
- if (STRCASEEQ(type, "phyp"))
- *typeVer = LIBVIR_VERSION_NUMBER;
-# endif
-# if WITH_OPENVZ
- if (STRCASEEQ(type, "OpenVZ"))
- *typeVer = LIBVIR_VERSION_NUMBER;
-# endif
-# if WITH_VMWARE
- if (STRCASEEQ(type, "VMware"))
- *typeVer = LIBVIR_VERSION_NUMBER;
-# endif
-# if WITH_VBOX
- if (STRCASEEQ(type, "VBox"))
- *typeVer = LIBVIR_VERSION_NUMBER;
-# endif
-# if WITH_UML
- if (STRCASEEQ(type, "UML"))
- *typeVer = LIBVIR_VERSION_NUMBER;
-# endif
-# if WITH_ONE
- if (STRCASEEQ(type, "ONE"))
- *typeVer = LIBVIR_VERSION_NUMBER;
-# endif
-# if WITH_ESX
- if (STRCASEEQ(type, "ESX"))
- *typeVer = LIBVIR_VERSION_NUMBER;
-# endif
-# if WITH_XENAPI
- if (STRCASEEQ(type, "XenAPI"))
- *typeVer = LIBVIR_VERSION_NUMBER;
-# endif
-# if WITH_REMOTE
- if (STRCASEEQ(type, "Remote"))
- *typeVer = remoteVersion();
-# endif
- if (*typeVer == 0) {
- virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
- goto error;
- }
-#endif /* WITH_DRIVER_MODULES */
- }
return 0;
error:
--
1.7.0.4
13 years, 5 months
[libvirt] [PATCH v2 0/3] add support for changing blkio parameters for inactive domains
by Hu Tao
This series enables user to change blkio parameters for inactive
domains from virsh command line.
CHANGES:
v1-v2:
- unify PARAM_CONFIG/PARAM_LIVE/PARAM_CURRENT
Hu Tao (3):
unify PARAM_CURRENT/PARAM_LIVE/PARAM_CONFIG flags
update qemuDomainGetBlkioParameters to use flags
Update qemuDomainSetBlkioParameters to use flags
include/libvirt/libvirt.h.in | 58 ++----
src/esx/esx_driver.c | 10 +-
src/libvirt.c | 4 +-
src/openvz/openvz_driver.c | 10 +-
src/qemu/qemu_driver.c | 442 ++++++++++++++++++++++++++----------------
src/test/test_driver.c | 42 ++--
src/uml/uml_driver.c | 4 +-
src/vbox/vbox_tmpl.c | 22 +-
tools/virsh.c | 74 ++++----
9 files changed, 371 insertions(+), 295 deletions(-)
--
1.7.3.1
13 years, 5 months
[libvirt] [PATCH v2] graphics: add support for action_if_connected in qemu
by Michal Prívozník
From: Michal Privoznik <mprivozn(a)redhat.com>
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)
---
diff to v1:
-Eric's review suggestions included
-update 'Since'
docs/formatdomain.html.in | 13 +++++++++++--
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 | 15 ++++++++++++---
6 files changed, 93 insertions(+), 8 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 225e0c8..5dd54ca 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1801,7 +1801,11 @@ qemu-kvm -net nic,model=? /dev/null
in clear text. The <code>keymap</code> attribute specifies the keymap
to use. It is possible to set a limit on the validity of the password
be giving an timestamp <code>passwdValidTo='2010-04-09T15:51:00'</code>
- assumed to be in UTC. NB, this may not be supported by all hypervisors.<br/>
+ assumed to be in UTC. <span class="since">Since 0.8.5</span>
+ The <code>connected</code> attribute allows control of connected client
+ during password changes. VNC accepts <code>keep</code> value only.
+ <span class="since">since 0.9.3</span>
+ NB, this may not be supported by all hypervisors.<br/>
<br/>
Rather than using listen/port, QEMU supports a <code>socket</code>
attribute for listening on a unix domain socket path.
@@ -1820,7 +1824,12 @@ qemu-kvm -net nic,model=? /dev/null
in clear text. The <code>keymap</code> attribute specifies the keymap
to use. It is possible to set a limit on the validity of the password
be giving an timestamp <code>passwdValidTo='2010-04-09T15:51:00'</code>
- assumed to be in UTC. NB, this may not be supported by all hypervisors.
+ assumed to be in UTC. <span class="since">Since 0.8.5</span>
+ The <code>connected</code> attribute allows control of connected client
+ during password changes. SPICE accepts <code>keep</code> to keep client
+ connected, <code>disconnect</code> to disconnect client and
+ <code>fail</code> to fail changing password. <span class="since">Since 0.9.3</span>
+ NB, this may not be supported by all hypervisors.
<span class="since">"spice" since 0.8.6</span>.
</p>
<p>
diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index 0be0371..e71b683 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -1250,6 +1250,13 @@
<data type="dateTime"/>
</attribute>
</optional>
+ <optional>
+ <attribute name="connected">
+ <choice>
+ <value>keep</value>
+ </choice>
+ </attribute>
+ </optional>
</group>
<group>
<attribute name="type">
@@ -1293,6 +1300,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 0d9fef4..19f22e0 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -311,6 +311,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",
@@ -3892,9 +3899,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");
@@ -3935,6 +3945,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;
}
@@ -4004,7 +4036,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");
@@ -4140,7 +4173,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;
@@ -9075,6 +9109,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 41c8136..6bfc337 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -640,12 +640,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 {
@@ -1546,6 +1556,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 e6ab870..c3ce412 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -267,6 +267,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 fe47896..ead2cfc 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1059,10 +1059,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,
@@ -1074,6 +1076,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;
}
@@ -1102,6 +1105,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,
@@ -1113,6 +1117,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;
@@ -1797,16 +1802,20 @@ qemuDomainChangeGraphicsPasswords(struct qemud_driver *driver,
qemuDomainObjPrivatePtr priv = vm->privateData;
time_t now = time(NULL);
char expire_time [64];
+ const char *connected;
int ret;
if (!auth->passwd && !driver->vncPassword)
return 0;
+ if (auth->connected)
+ connected = virDomainGraphicsAuthConnectedTypeToString(auth->connected)l
+
qemuDomainObjEnterMonitorWithDriver(driver, vm);
ret = qemuMonitorSetPassword(priv->mon,
type,
auth->passwd ? auth->passwd : defaultPasswd,
- NULL);
+ connected);
if (ret == -2) {
if (type != VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
--
1.7.5.rc3
13 years, 5 months