[libvirt] [PATCH] Fix ID field in virDomainPtr after starting Xen guest
by Daniel P. Berrange
* src/xend_internal.c: Lookup guest after starting persistent
config in order to refresh the domain ID field
---
src/xend_internal.c | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/src/xend_internal.c b/src/xend_internal.c
index 7bcee7d..459b6bc 100644
--- a/src/xend_internal.c
+++ b/src/xend_internal.c
@@ -4537,6 +4537,8 @@ virDomainPtr xenDaemonDomainDefineXML(virConnectPtr conn, const char *xmlDesc) {
int xenDaemonDomainCreate(virDomainPtr domain)
{
xenUnifiedPrivatePtr priv;
+ int ret;
+ virDomainPtr tmp;
if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
@@ -4549,7 +4551,17 @@ int xenDaemonDomainCreate(virDomainPtr domain)
if (priv->xendConfigVersion < 3)
return(-1);
- return xend_op(domain->conn, domain->name, "op", "start", NULL);
+ ret = xend_op(domain->conn, domain->name, "op", "start", NULL);
+
+ if (ret != -1) {
+ /* Need to force a refresh of this object's ID */
+ tmp = virDomainLookupByName(domain->conn, domain->name);
+ if (tmp) {
+ domain->id = tmp->id;
+ virDomainFree(tmp);
+ }
+ }
+ return ret;
}
int xenDaemonDomainUndefine(virDomainPtr domain)
--
1.6.4
15 years, 2 months
[libvirt] Save & Restore Synchronization
by Erkan Unal
Hi,
I am using libvirt for qemu/kvm. I have following questions in terms of
save and restore (Version 0.6.2):
1) As I checked the libvirt code, restore command is asynchronous. There
is a macro called VIR_EXEC_NONBLOCK but there is no macro called
VIR_EXEC_BLOCK. Is it possible to execute the restore in blocking mode
so that I can measure the whole restore time?
2) I tried to measure the time spent to save the VM. I am executing save
command and getting a timing. However when I execute the following
operations in order I got an error right after script issues the
restore operation (No delay between them):
"save->restore->save"
... the error is:
20:19:02.478: error : internal error Unable to open monitor path /dev/pts/3
libvir: QEMU error : internal error Unable to open monitor path /dev/pts/3
20:19:02.478: error : internal error unable to start guest: char device
redirected to /dev/pts/3
inet_listen: bind(ipv4,127.0.0.1,5912): Address already in use
inet_listen: FAILED
libvir: QEMU error : internal error unable to start guest: char device
redirected to /dev/pts/3
inet_listen: bind(ipv4,127.0.0.1,5912): Address already in use
inet_listen: FAILED
20:19:02.482: error : operation failed: failed to start VM
libvir: QEMU error : operation failed: failed to start VM
error: Failed to restore domain from /path/to/the/save/file
error: operation failed: failed to start VM
(You can find the detailed error report in the attachement when
LIBVIRT_DEBUG flag is 1)
I think that some of the cleanup is non-blocking which are cleanup of
pty device and vncserver. However, I am not sure if destroying the qemu
process is asynchronous??
P.S.: If I put one second delay between first save and restore, there is
no error. Save and restore work fine.
Thanks,
Erkan Unal
20:26:07.506: debug : virInitialize:287 : register drivers
20:26:07.506: debug : virRegisterDriver:660 : registering Test as driver 0
20:26:07.506: debug : virRegisterNetworkDriver:560 : registering Test as network driver 0
20:26:07.506: debug : virRegisterStorageDriver:591 : registering Test as storage driver 0
20:26:07.506: debug : virRegisterDeviceMonitor:622 : registering Test as device driver 0
20:26:07.506: debug : virRegisterDriver:660 : registering Xen as driver 1
20:26:07.506: debug : virRegisterDriver:660 : registering OPENVZ as driver 2
20:26:07.506: debug : virRegisterDriver:660 : registering remote as driver 3
20:26:07.506: debug : virRegisterNetworkDriver:560 : registering remote as network driver 1
20:26:07.506: debug : virRegisterStorageDriver:591 : registering remote as storage driver 1
20:26:07.506: debug : virRegisterDeviceMonitor:622 : registering remote as device driver 1
20:26:07.506: debug : virConnectOpenAuth:1089 : name=qemu:///session, auth=0x7fa21cbae660, flags=0
20:26:07.506: debug : do_open:909 : name "qemu:///session" to URI components:
scheme qemu
opaque (null)
authority (null)
server (null)
user (null)
port 0
path /session
20:26:07.506: debug : do_open:919 : trying driver 0 (Test) ...
20:26:07.506: debug : do_open:925 : driver 0 Test returned DECLINED
20:26:07.506: debug : do_open:919 : trying driver 1 (Xen) ...
20:26:07.506: debug : do_open:925 : driver 1 Xen returned DECLINED
20:26:07.506: debug : do_open:919 : trying driver 2 (OPENVZ) ...
20:26:07.506: debug : do_open:925 : driver 2 OPENVZ returned DECLINED
20:26:07.506: debug : do_open:919 : trying driver 3 (remote) ...
20:26:07.506: debug : remoteOpen:974 : Auto-remote UNIX socket
20:26:07.506: debug : remoteOpen:992 : Auto-spawn user daemon instance
20:26:07.506: debug : doRemoteOpen:511 : proceeding with name = qemu:///session
20:26:07.507: debug : call:6473 : Doing call 66 (nil)
20:26:07.507: debug : call:6543 : We have the buck 66 0x7fa21bdb5010 0x7fa21bdb5010
20:26:07.507: debug : processCallRecvLen:6131 : Got length, now need 36 total (32 more)
20:26:07.507: debug : processCalls:6399 : Giving up the buck 66 0x7fa21bdb5010 (nil)
20:26:07.507: debug : call:6574 : All done with our call 66 (nil) 0x7fa21bdb5010
20:26:07.507: debug : call:6473 : Doing call 1 (nil)
20:26:07.507: debug : call:6543 : We have the buck 1 0xf86d80 0xf86d80
20:26:07.509: debug : processCallRecvLen:6131 : Got length, now need 28 total (24 more)
20:26:07.509: debug : processCalls:6399 : Giving up the buck 1 0xf86d80 (nil)
20:26:07.509: debug : call:6574 : All done with our call 1 (nil) 0xf86d80
20:26:07.509: debug : doRemoteOpen:822 : Adding Handler for remote events
20:26:07.509: debug : doRemoteOpen:829 : virEventAddHandle failed: No addHandleImpl defined. continuing without events.
20:26:07.509: debug : do_open:925 : driver 3 remote returned SUCCESS
20:26:07.509: debug : do_open:945 : network driver 0 Test returned DECLINED
20:26:07.509: debug : do_open:945 : network driver 1 remote returned SUCCESS
20:26:07.509: debug : do_open:967 : storage driver 0 Test returned DECLINED
20:26:07.509: debug : do_open:967 : storage driver 1 remote returned SUCCESS
20:26:07.510: debug : do_open:988 : node driver 0 Test returned DECLINED
20:26:07.510: debug : do_open:988 : node driver 1 remote returned SUCCESS
20:26:07.510: debug : virDomainRestore:2012 : conn=0xf82430, from=/path/to/save/file
20:26:07.510: debug : call:6473 : Doing call 54 (nil)
20:26:07.510: debug : call:6543 : We have the buck 54 0xf86d80 0xf86d80
20:26:07.625: error : internal error Unable to open monitor path /dev/pts/3
libvir: QEMU error : internal error Unable to open monitor path /dev/pts/3
20:26:07.625: error : internal error unable to start guest: char device redirected to /dev/pts/3
inet_listen: bind(ipv4,127.0.0.1,5912): Address already in use
inet_listen: FAILED
libvir: QEMU error : internal error unable to start guest: char device redirected to /dev/pts/3
inet_listen: bind(ipv4,127.0.0.1,5912): Address already in use
inet_listen: FAILED
20:26:07.629: error : operation failed: failed to start VM
libvir: QEMU error : operation failed: failed to start VM
20:26:07.629: debug : processCallRecvLen:6131 : Got length, now need 160 total (156 more)
20:26:07.629: debug : processCalls:6399 : Giving up the buck 54 0xf86d80 (nil)
20:26:07.629: debug : call:6574 : All done with our call 54 (nil) 0xf86d80
error: Failed to restore domain from /path/to/save/file
error: operation failed: failed to start VM
20:26:07.629: debug : virConnectClose:1107 : conn=0xf82430
20:26:07.629: debug : call:6473 : Doing call 2 (nil)
20:26:07.629: debug : call:6543 : We have the buck 2 0xf86d80 0xf86d80
20:26:07.629: debug : processCallRecvLen:6131 : Got length, now need 28 total (24 more)
20:26:07.629: debug : processCalls:6399 : Giving up the buck 2 0xf86d80 (nil)
20:26:07.629: debug : call:6574 : All done with our call 2 (nil) 0xf86d80
20:26:07.629: debug : virUnrefConnect:210 : unref connection 0xf82430 1
20:26:07.629: debug : virReleaseConnect:171 : release connection 0xf82430
15 years, 2 months
[libvirt] libvirt socket closed unexpectedly / libvirt broken pipe
by Dave
Hello,
I'm trying to get eucalyptus v1.5.2 working with debian lenny, the relevant versions of libvirt software installed are from the apt-get repos, which are:
# dpkg -l|grep libvirt
ii libvirt-bin 0.4.6-10 the programs for the libvirt library
ii libvirt0 0.4.6-10 library for interfacing with different virtualization systems
The the conf file looks like so:
# cat libvirtd.conf|grep -v '#'
unix_sock_group = "libvirt"
unix_sock_rw_perms = "0770"
auth_unix_ro = "none"
auth_unix_rw = "none"
-----
my eucalyptus nc.log has the following error, which i believe is the issue, basically any instance i start, terminates about a minute later by itself, any guidance or help is much appreciated
[Sat Aug 15 03:20:41 2009][004602][EUCAERROR ] libvirt: socket closed unexpectedly (code=39)
[Sat Aug 15 03:20:43 2009][004602][EUCAERROR ] libvirt: Broken pipe (code=38)
thoughts? ideas?
15 years, 2 months
[libvirt] [PATCH] Allow libvirtd to RPC to external libvirtd.
by Chris Lalancette
Allow the daemon itself to make RPCs to an external libvirtd, but only if
the URI is fully specified. While this isn't used at the moment, it will
be for the tunnelled migration support in the future.
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
src/remote_internal.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/remote_internal.c b/src/remote_internal.c
index bc69c70..a416cf3 100644
--- a/src/remote_internal.c
+++ b/src/remote_internal.c
@@ -1001,7 +1001,7 @@ remoteOpen (virConnectPtr conn,
int ret, rflags = 0;
const char *autostart = getenv("LIBVIRT_AUTOSTART");
- if (inside_daemon)
+ if (inside_daemon && (!conn->uri || (conn->uri && !conn->uri->server)))
return VIR_DRV_OPEN_DECLINED;
if (!(priv = remoteAllocPrivateData(conn)))
--
1.6.0.6
15 years, 2 months
[libvirt] On pidfile security and using -daemonize to start qemu/kvm
by Charles Duffy
I had a brief conversation with Daniel Berrange on IRC this morning
regarding race conditions in libvirt's invocation of qemu domains. The
preferred approach from qemu's maintainership is using -daemonize at
invocation, and then waiting for the process to exit before attempting
to connect to the monitor; after this occurs, qemu guarantees monitor
availability, so no retry/timeout behavior is necessary.
Dan pointed out an issue with this approach:
To determine the PID of the qemu instance started, the -pidfile argument
to qemu needs to be used with -daemonize. However, -pidfile writes the
requested pidfile with qemu's permissions; if the guest were subverted,
it could rewrite its pidfile and lead libvirt to kill other, arbitrary
processes.
Neither changing permissions with -runas rather than prior to invocation
nor chown'ing the pidfile from libvirt after creation helps, as qemu
keeps a file handle on it open throughout operation (to maintain a POSIX
lock on the file).
However, a workaround exists, and it meshes well with a security fix
which needs to be implemented anyhow:
At present, on initial startup or libvirtd restart, we read the PIDs
associated with vCPUs from the monitor in virDetectVcpuPIDs(); doing
this on libvirtd restart poses a security risk for the reason given
above, so we need to have libvirtd record the PIDs on initial startup
(before any untrusted code within the guest is ever run) regardless.
If we also read the libvirtd pidfile at this same early time (before the
guest has been started and thus had an opportunity to run untrusted
code) and include its contents when writing out the vCPU PIDs, this
would eliminate the issue with pidfile ownership blocking use of -daemonize.
Thoughts?
15 years, 2 months
[libvirt] [PATCH] xen_internal.c: remove two unused local variables
by Jim Meyering
Obviously unnecessary.
Maybe someone had plans for these long ago?
>From 94730ec1d99076cd18b04b950adad7c7a576071f Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Thu, 3 Sep 2009 17:11:14 +0200
Subject: [PATCH] xen_internal.c: remove two unused local variables
* src/xen_internal.c (xenHypervisorSetSchedulerParameters): Remove
set-but-never-used local variables, cap_set and weight_set.
---
src/xen_internal.c | 5 -----
1 files changed, 0 insertions(+), 5 deletions(-)
diff --git a/src/xen_internal.c b/src/xen_internal.c
index ae78f84..30fd8bd 100644
--- a/src/xen_internal.c
+++ b/src/xen_internal.c
@@ -1299,9 +1299,6 @@ xenHypervisorSetSchedulerParameters(virDomainPtr domain,
TODO
return(-1);
case XEN_SCHEDULER_CREDIT: {
- int weight_set = 0;
- int cap_set = 0;
-
memset(&op_dom, 0, sizeof(op_dom));
op_dom.cmd = XEN_V2_OP_SCHEDULER;
op_dom.domain = (domid_t) domain->id;
@@ -1326,7 +1323,6 @@ xenHypervisorSetSchedulerParameters(virDomainPtr domain,
return(-1);
}
op_dom.u.getschedinfo.u.credit.weight = val;
- weight_set = 1;
} else if (STREQ (params[i].field, str_cap) &&
params[i].type == VIR_DOMAIN_SCHED_FIELD_UINT) {
val = params[i].value.ui;
@@ -1336,7 +1332,6 @@ xenHypervisorSetSchedulerParameters(virDomainPtr domain,
return(-1);
}
op_dom.u.getschedinfo.u.credit.cap = val;
- cap_set = 1;
} else {
virXenErrorFunc (domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__,
"Credit scheduler accepts 'cap' and 'weight' integer parameters",
--
1.6.4.2.395.ge3d52
15 years, 2 months
[libvirt] [PATCH] python: let libvirt_virConnectDomainEventCallback indicate success
by Jim Meyering
First dead-store-related bug fix:
>From 6024fb05dfa2dd408ad79abbac88791f5048af11 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Thu, 3 Sep 2009 14:09:49 +0200
Subject: [PATCH] python: let libvirt_virConnectDomainEventCallback indicate success
* python/libvir.c (libvirt_virConnectDomainEventCallback): Return 0
when successful, rather than always returning -1.
clang flagged this function for its dead-store of "ret=0".
Once "ret" was set to 0, it was never used, and
the function would always return -1.
---
python/libvir.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/python/libvir.c b/python/libvir.c
index e2c196a..0c00b80 100644
--- a/python/libvir.c
+++ b/python/libvir.c
@@ -4,7 +4,7 @@
* entry points where an automatically generated stub is
* unpractical
*
- * Copyright (C) 2005, 2007, 2008 Red Hat, Inc.
+ * Copyright (C) 2005, 2007-2009 Red Hat, Inc.
*
* Daniel Veillard <veillard(a)redhat.com>
*/
@@ -1812,7 +1812,7 @@ libvirt_virConnectDomainEventCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
cleanup:
LIBVIRT_RELEASE_THREAD_STATE;
- return -1;
+ return ret;
}
static PyObject *
--
1.6.4.2.395.ge3d52
15 years, 2 months
[libvirt] [PATCH 0/3] QEMU directory/monitor socket fixes/cleanup
by Daniel P. Berrange
This patch series does three things
- Moves QEMU monitor sockets in /var/lib/libvirt/qemu, since this is
created file and thus should be separate from libvirtd created data
to avoid risk from QEMU compromise.
- Sets QEMU directory ownership to match configured qemu user/group
- Fixes a minor memory leak / socket unlink
15 years, 2 months
[libvirt] [PATCH 2/2]: VirtualBox: Updated vboxNetworkUndefine() and vboxNetworkDestroy()
by Pritesh Kothari
Hi All,
I have made some changes to the functions vboxNetworkCreateXML(),
vboxNetworkDefineXML(), vboxNetworkUndefine() and vboxNetworkDestroy() to handle
multiple host only interfaces as multiple host only interfaces are supported
by VirtualBox 3.0 and greater.
The patch's are as below:
PATCH 1/2: Merged vboxNetworkCreateXML() and vboxNetworkDefineXML() and added
code to handle multiple hostonly interfaces.
PATCH 2/2: Merged vboxNetworkUndefine() and vboxNetworkDestroy() and added code
to handle multiple hostonly interfaces.
Regards,
Pritesh
15 years, 2 months
[libvirt] [PATCH] esx_vi: remove unreachable code
by Jim Meyering
This removes dead code and suppresses a warning from clang.
However, see below:
>From 2ed548cbe948aa7ef37ccd121bd084bd05019ac8 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Thu, 3 Sep 2009 16:35:47 +0200
Subject: [PATCH] esx_vi: remove unreachable code
* src/esx/esx_vi.c (esxVI_Enumeration_Deserialize): Remove
unreachable code.
---
src/esx/esx_vi.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index 0da908b..c689a7a 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -857,8 +857,6 @@ esxVI_Enumeration_Deserialize(virConnectPtr conn,
failure:
goto cleanup;
-
- result = -1;
}
--------------------------------------------
This function does not allow the caller to distinguish
via its return value whether it has failed.
It always returns 0.
I see that this function's return value is used in numerous places
(each esxVI_.*Deserialize function), so this should be fixed.
int
esxVI_Enumeration_Deserialize(virConnectPtr conn,
const esxVI_Enumeration *enumeration,
xmlNodePtr node, int *value)
{
int i;
int result = 0;
char *name = NULL;
if (value == NULL) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR, "Invalid argument");
goto failure;
}
*value = 0; /* undefined */
if (esxVI_String_DeserializeValue(conn, node, &name) < 0) {
goto failure;
}
for (i = 0; enumeration->values[i].name != NULL; ++i) {
if (STREQ(name, enumeration->values[i].name)) {
*value = enumeration->values[i].value;
goto cleanup;
}
}
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR, "Unknown value '%s' for %s",
name, enumeration->type);
cleanup:
VIR_FREE(name);
return result;
failure:
goto cleanup;
}
15 years, 2 months