[libvirt] [PATCH 0/2] fix some bugs in libvirtd
by Wen Congyang
Steps to reproduce this bug:
1. service libvirtd start
2. virsh start <domain>
3. kill -STOP $(cat /var/run/libvirt/qemu/<domain>.pid)
4. service libvirtd restart
5. kill -9 $(cat /var/run/libvirt/qemu/<domain>.pid)
Then libvirtd will core dump or be in deadlock state.
Make sure that json is built into libvirt and the version
of qemu is newer than 0.13.0.
Wen Congyang (2):
avoid vm to be deleted if qemuConnectMonitor failed
avoid closing monitor twice
src/qemu/qemu_driver.c | 31 ++++++++++++++++++++++---------
src/qemu/qemu_monitor.c | 10 ++++++++++
2 files changed, 32 insertions(+), 9 deletions(-)
13 years, 9 months
[libvirt] [PATCH] Fix conflicts with glibc globals
by Davidlohr Bueso
When compiling libvirt with GCC 3.4.6 the following warning is being triggered quite a lot:
util/memory.h:60: warning: declaration of 'remove' shadows a global declaration
/usr/include/stdio.h:175: warning: shadowed declaration is here
Fix this by renaming the parameter to 'toremove'.
---
src/util/memory.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/util/memory.h b/src/util/memory.h
index 750a6b0..66b4c42 100644
--- a/src/util/memory.h
+++ b/src/util/memory.h
@@ -57,7 +57,7 @@ int virExpandN(void *ptrptr, size_t size, size_t *count, size_t add)
int virResizeN(void *ptrptr, size_t size, size_t *alloc, size_t count,
size_t desired)
ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3);
-void virShrinkN(void *ptrptr, size_t size, size_t *count, size_t remove)
+void virShrinkN(void *ptrptr, size_t size, size_t *count, size_t toremove)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3);
int virAllocVar(void *ptrptr,
size_t struct_size,
--
1.7.1
13 years, 9 months
[libvirt] [PATCH] Don't sleep in poll() if there is existing SASL decoded data
by Daniel P. Berrange
In the SASL codepath we typically read far more data off the
wire than we immediately need. When using a connection from a
single thread this isn't a problem, since only our reply will
be pending (or an event we can handle directly). When using a
connection from multiple threads though, we may read the data
from replies from other threads. If those replies occur after
our own reply, they'll not be processed. The other thread will
then go into poll() and wait for its reply which has already
been received and decoded. The solution is to set poll() timeout
to 0 if there is pending SASL data.
* src/remote/remote_driver.c: Don't sleep in poll() if SASL
data exists
---
src/remote/remote_driver.c | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index b52b780..452ab38 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -10222,6 +10222,14 @@ remoteIOEventLoop(virConnectPtr conn,
#ifdef HAVE_PTHREAD_SIGMASK
sigset_t oldmask, blockedsigs;
#endif
+ int timeout = -1;
+
+ /* If we have existing SASL decoded data we
+ * don't want to sleep in the poll(), just
+ * check if any other FDs are also ready
+ */
+ if (priv->saslDecoded)
+ timeout = 0;
fds[0].events = fds[0].revents = 0;
fds[1].events = fds[1].revents = 0;
@@ -10257,7 +10265,7 @@ remoteIOEventLoop(virConnectPtr conn,
#endif
repoll:
- ret = poll(fds, ARRAY_CARDINALITY(fds), -1);
+ ret = poll(fds, ARRAY_CARDINALITY(fds), timeout);
if (ret < 0 && errno == EAGAIN)
goto repoll;
@@ -10267,6 +10275,12 @@ remoteIOEventLoop(virConnectPtr conn,
remoteDriverLock(priv);
+ /* If we have existing SASL decoded data, pretend
+ * the socket became readable so we consume it
+ */
+ if (priv->saslDecoded)
+ fds[0].revents |= POLLIN;
+
if (fds[1].revents) {
ssize_t s;
DEBUG0("Woken up from poll by other thread");
--
1.7.3.5
13 years, 9 months
[libvirt] New sub-project libvirt-snmp
by Michal Prívozník
Hi,
I'd like to let you know and review the new project libvirt-snmp.
It's aim is to provide snmp functionality to libvirt. Right now it
supports only VM lifecycle stuff (start, suspend, destroy, ...)
and gathering info.
The sources are available here:
git clone git://libvirt.org/libvirt-snmp.git
to install please see INSTALL file, some examples are in src/README.txt
We can also create an .rpm (see libvirt-snmp.spec.in) but thing is
in order to run libvirt-snmp subagent, snmpd.conf needs to be edited
first. Is there a way I can solve this? I mean overwriting it is ugly.
Or should i leave it just in the installation docs?
Any suggestions appreciated.
Michal Privoznik
13 years, 9 months
[libvirt] [PATCH 0/3] Introduce QEMUD_CMD_FLAG_PCI_MULTIBUS for -device bus=pci(.0)
by Niels de Vos
This series introduces a new (fake) flag for the qemu binary. The flag
QEMUD_CMD_FLAG_PCI_MULTIBUS is used to mark an architecture to be able to
have multiple PCI-busses. When executing qemu, -device should take either a
bus-string like "pci" or "pci.0". Where the latter can be used to select the
appropriate bus for the PCI-device.
Currently libvirt breaks starting qemu-system-$ARCH as the -device option
always sets bus=pci.0. On most architectures, there is no PCI-Multibus
support in qemu. This series enables libvirt to select the architectures that
support PCI-multibus and sets the flag for x86_64 and i686 only.
Reference:
- https://bugzilla.redhat.com/show_bug.cgi?id=667345
Kind regards,
Niels
--
Niels de Vos (3):
qemuBuildDeviceAddressStr() checks for QEMUD_CMD_FLAG_PCI_MULTIBUS
Set QEMUD_CMD_FLAG_PCI_MULTIBUS for x86_64 and i686 architectures
Add myself to AUTHORS
AUTHORS | 1 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 67 ++++++++++++++++++++++++++---------------
src/qemu/qemu_command.h | 18 +++++++----
src/qemu/qemu_hotplug.c | 5 ++-
5 files changed, 59 insertions(+), 33 deletions(-)
--
1.7.3.5
13 years, 9 months
[libvirt] [PATCH] qemu: Add shortcut for HMP pass through
by Jiri Denemark
Currently users who want to use virDomainQemuMonitorCommand() API or
it's virsh equivalent has to use the same protocol as libvirt uses for
communication to qemu. Since the protocol is QMP with current qemu and
HMP much more usable for humans, one ends up typing something like the
following:
virsh qemu-monitor-command DOM \
'{"execute":"human-monitor-command","arguments":{"command-line":"info kvm"}}'
which is not a very convenient way of debugging qemu.
This patch introduces --hmp option to qemu-monitor-command, which says
that the provided command is in HMP. If libvirt uses QMP to talk with
qemu, the command will automatically be converted into QMP. So the
example above is simplified to just
virsh qemu-monitor-command --hmp DOM "info kvm"
Also the result is converted from
{"return":"kvm support: enabled\r\n"}
to just plain HMP:
kvm support: enabled
If libvirt talks to qemu in HMP, --hmp flag is obviously a noop.
---
include/libvirt/libvirt-qemu.h | 5 +++++
src/internal.h | 1 +
src/qemu/qemu_driver.c | 7 +++++--
src/qemu/qemu_monitor.c | 9 ++++++---
src/qemu/qemu_monitor.h | 5 ++++-
src/qemu/qemu_monitor_json.c | 27 ++++++++++++++++++++++++---
src/qemu/qemu_monitor_json.h | 3 ++-
tools/virsh.c | 7 ++++++-
8 files changed, 53 insertions(+), 11 deletions(-)
diff --git a/include/libvirt/libvirt-qemu.h b/include/libvirt/libvirt-qemu.h
index 9c191c7..9257c2f 100644
--- a/include/libvirt/libvirt-qemu.h
+++ b/include/libvirt/libvirt-qemu.h
@@ -20,6 +20,11 @@
extern "C" {
# endif
+enum {
+ VIR_DOMAIN_QEMU_MONITOR_COMMAND_DEFAULT = 0,
+ VIR_DOMAIN_QEMU_MONITOR_COMMAND_HMP = (1 << 0), /* cmd is in HMP */
+} virDomainQemuMonitorCommandFlags;
+
int virDomainQemuMonitorCommand(virDomainPtr domain, const char *cmd,
char **result, unsigned int flags);
diff --git a/src/internal.h b/src/internal.h
index 038b862..dc1d9cb 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -38,6 +38,7 @@
# define N_(str) str
# include "libvirt/libvirt.h"
+# include "libvirt/libvirt-qemu.h"
# include "libvirt/virterror.h"
# include "libvirt_internal.h"
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 23e0db0..bb50264 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -10226,8 +10226,9 @@ static int qemuDomainMonitorCommand(virDomainPtr domain, const char *cmd,
virDomainObjPtr vm = NULL;
int ret = -1;
qemuDomainObjPrivatePtr priv;
+ bool hmp;
- virCheckFlags(0, -1);
+ virCheckFlags(VIR_DOMAIN_QEMU_MONITOR_COMMAND_HMP, -1);
qemuDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, domain->uuid);
@@ -10253,10 +10254,12 @@ static int qemuDomainMonitorCommand(virDomainPtr domain, const char *cmd,
priv->monitor_warned = 1;
}
+ hmp = !!(flags & VIR_DOMAIN_QEMU_MONITOR_COMMAND_HMP);
+
if (qemuDomainObjBeginJobWithDriver(driver, vm) < 0)
goto cleanup;
qemuDomainObjEnterMonitorWithDriver(driver, vm);
- ret = qemuMonitorArbitraryCommand(priv->mon, cmd, result);
+ ret = qemuMonitorArbitraryCommand(priv->mon, cmd, result, hmp);
qemuDomainObjExitMonitorWithDriver(driver, vm);
if (qemuDomainObjEndJob(vm) == 0) {
vm = NULL;
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 0c14277..fdb6b79 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -2007,14 +2007,17 @@ int qemuMonitorDeleteSnapshot(qemuMonitorPtr mon, const char *name)
return ret;
}
-int qemuMonitorArbitraryCommand(qemuMonitorPtr mon, const char *cmd, char **reply)
+int qemuMonitorArbitraryCommand(qemuMonitorPtr mon,
+ const char *cmd,
+ char **reply,
+ bool hmp)
{
int ret;
- DEBUG("mon=%p, cmd=%s, reply=%p", mon, cmd, reply);
+ DEBUG("mon=%p, cmd=%s, reply=%p, hmp=%d", mon, cmd, reply, hmp);
if (mon->json)
- ret = qemuMonitorJSONArbitraryCommand(mon, cmd, reply);
+ ret = qemuMonitorJSONArbitraryCommand(mon, cmd, reply, hmp);
else
ret = qemuMonitorTextArbitraryCommand(mon, cmd, reply);
return ret;
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 92c550b..0ea1330 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -397,7 +397,10 @@ int qemuMonitorCreateSnapshot(qemuMonitorPtr mon, const char *name);
int qemuMonitorLoadSnapshot(qemuMonitorPtr mon, const char *name);
int qemuMonitorDeleteSnapshot(qemuMonitorPtr mon, const char *name);
-int qemuMonitorArbitraryCommand(qemuMonitorPtr mon, const char *cmd, char **reply);
+int qemuMonitorArbitraryCommand(qemuMonitorPtr mon,
+ const char *cmd,
+ char **reply,
+ bool hmp);
/**
* When running two dd process and using <> redirection, we need a
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index ca06e7e..9ac12f8 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -2457,20 +2457,41 @@ int qemuMonitorJSONDeleteSnapshot(qemuMonitorPtr mon, const char *name)
int qemuMonitorJSONArbitraryCommand(qemuMonitorPtr mon,
const char *cmd_str,
- char **reply_str)
+ char **reply_str,
+ bool hmp)
{
virJSONValuePtr cmd = NULL;
virJSONValuePtr reply = NULL;
int ret = -1;
- cmd = virJSONValueFromString(cmd_str);
+ if (!hmp) {
+ cmd = virJSONValueFromString(cmd_str);
+ } else {
+ cmd = qemuMonitorJSONMakeCommand("human-monitor-command",
+ "s:command-line", cmd_str,
+ NULL);
+ }
+
if (!cmd)
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
goto cleanup;
- *reply_str = virJSONValueToString(reply);
+ if (!hmp) {
+ *reply_str = virJSONValueToString(reply);
+ } else if (qemuMonitorJSONCheckError(cmd, reply)) {
+ goto cleanup;
+ } else {
+ const char *data;
+ if (!(data = virJSONValueObjectGetString(reply, "return"))) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("human monitor command was missing return data"));
+ goto cleanup;
+ }
+ *reply_str = strdup(data);
+ }
+
if (!(*reply_str))
goto cleanup;
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 4c47f10..4ae472a 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -209,6 +209,7 @@ int qemuMonitorJSONDeleteSnapshot(qemuMonitorPtr mon, const char *name);
int qemuMonitorJSONArbitraryCommand(qemuMonitorPtr mon,
const char *cmd_str,
- char **reply_str);
+ char **reply_str,
+ bool hmp);
#endif /* QEMU_MONITOR_JSON_H */
diff --git a/tools/virsh.c b/tools/virsh.c
index 4533d38..59d3de5 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -9932,6 +9932,7 @@ static const vshCmdInfo info_qemu_monitor_command[] = {
static const vshCmdOptDef opts_qemu_monitor_command[] = {
{"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
{"cmd", VSH_OT_DATA, VSH_OFLAG_REQ, N_("command")},
+ {"hmp", VSH_OT_BOOL, 0, N_("command is in human monitor protocol")},
{NULL, 0, 0, NULL}
};
@@ -9942,6 +9943,7 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *cmd)
int ret = FALSE;
char *monitor_cmd;
char *result = NULL;
+ unsigned int flags = 0;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
@@ -9956,7 +9958,10 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
}
- if (virDomainQemuMonitorCommand(dom, monitor_cmd, &result, 0) < 0)
+ if (vshCommandOptBool(cmd, "hmp"))
+ flags |= VIR_DOMAIN_QEMU_MONITOR_COMMAND_HMP;
+
+ if (virDomainQemuMonitorCommand(dom, monitor_cmd, &result, flags) < 0)
goto cleanup;
printf("%s\n", result);
--
1.7.4
13 years, 9 months
[libvirt] [PATCH] Add check for binary existing in machine type probe
by Daniel P. Berrange
When probing machine types if the QEMU binary does not exist
we get a hard to diagnose error, due to the execve() in the
child failing
error: internal error Child process exited with status 1.
Add an explicit check so that we get
error: Cannot find QEMU binary /usr/libexec/qem3u-kvm: No such file or directory
* src/qemu/qemu_capabilities.c: Check for QEMU binary
---
src/qemu/qemu_capabilities.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 37a97aa..08c46be 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -172,6 +172,15 @@ qemuCapsProbeMachineTypes(const char *binary,
int ret = -1;
virCommandPtr cmd;
+ /* Make sure the binary we are about to try exec'ing exists.
+ * Technically we could catch the exec() failure, but that's
+ * in a sub-process so it's hard to feed back a useful error.
+ */
+ if (access(binary, X_OK) < 0) {
+ virReportSystemError(errno, _("Cannot find QEMU binary %s"), binary);
+ return -1;
+ }
+
cmd = virCommandNewArgList(binary, "-M", "?", NULL);
virCommandAddEnvPassCommon(cmd);
virCommandSetOutputBuffer(cmd, &output);
--
1.7.3.5
13 years, 9 months
[libvirt] [PATCH] Add a little more debugging for async events
by Daniel P. Berrange
To make it easier to investigate problems with async event
delivery, add two more debugging lines
* daemon/remote.c: Debug when an event is queued for dispatch
* src/remote/remote_driver.c: Debug when an event is received
for processing
---
daemon/remote.c | 2 ++
src/remote/remote_driver.c | 1 +
2 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index aa6a1a4..f8f6ffa 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -5670,6 +5670,8 @@ remoteDispatchDomainEventSend (struct qemud_client *client,
msg->async = 1;
msg->bufferLength = len;
msg->bufferOffset = 0;
+
+ VIR_DEBUG("Queue event %d %d", procnr, msg->bufferLength);
qemudClientMessageQueuePush(&client->tx, msg);
qemudUpdateClientEvent(client);
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 347b844..64af91c 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -9865,6 +9865,7 @@ processCallDispatch(virConnectPtr conn, struct private_data *priv,
break;
case REMOTE_MESSAGE: /* Async notifications */
+ VIR_DEBUG("Dispatch event %d %d", hdr.proc, priv->bufferLength);
rv = processCallDispatchMessage(conn, priv, flags & REMOTE_CALL_IN_OPEN,
&hdr, &xdr);
break;
--
1.7.3.5
13 years, 9 months
[libvirt] [PATCH] docs: more on qemu locking patterns
by Eric Blake
* src/qemu/THREADS.txt: Improve documentation.
---
I'm trying to make sure we don't have any qemu locking gotchas,
given that I've had a bug report of a qemu monitor callback
being able to result in a domaing being unreferenced while
in the middle of another command. As a first shot, I found that
our documentation needed some help.
Also, I have a question. I updated the documentation to match
existing code:
qemuDomainObjExitMonitor()
- - Acquires the virDomainObjPtr lock
- Releases the qemuMonitorObjPtr lock
+ - Acquires the virDomainObjPtr lock
But I'm wondering if that was correct, or if the code should instead
be swapped to match the original ordering in the documentation.
src/qemu/THREADS.txt | 100 ++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 77 insertions(+), 23 deletions(-)
diff --git a/src/qemu/THREADS.txt b/src/qemu/THREADS.txt
index 1af1b83..1e0b5ab 100644
--- a/src/qemu/THREADS.txt
+++ b/src/qemu/THREADS.txt
@@ -4,7 +4,7 @@
This document describes how thread safety is ensured throughout
the QEMU driver. The criteria for this model are:
- - Objects must never be exclusively locked for any pro-longed time
+ - Objects must never be exclusively locked for any prolonged time
- Code which sleeps must be able to time out after suitable period
- Must be safe against dispatch asynchronous events from monitor
@@ -36,11 +36,11 @@ There are a number of locks on various objects
Once the lock is held, you must *NOT* try to lock the driver. You must
release all virDomainObjPtr locks before locking the driver, or deadlock
- *WILL* occurr.
+ *WILL* occur.
If the lock needs to be dropped & then re-acquired for a short period of
time, the reference count must be incremented first using virDomainObjRef().
- If the reference count is incremented in this way, it is not neccessary
+ If the reference count is incremented in this way, it is not necessary
to have the driver locked when re-acquiring the dropped locked, since the
reference count prevents it being freed by another thread.
@@ -51,15 +51,20 @@ There are a number of locks on various objects
* qemuMonitorPrivatePtr: Job condition
- Since virDomainObjPtr lock must not be held during sleeps, the job condition
- provides additional protection for code making updates.
+ Since virDomainObjPtr lock must not be held during sleeps, the job
+ condition provides additional protection for code making updates.
- Immediately after acquiring the virDomainObjPtr lock, any method which intends
- to update state, must acquire the job condition. The virDomainObjPtr lock
- is released while blocking on this condition variable. Once the job condition
- is acquired a method can safely release the virDomainObjPtr lock whenever it
- hits a piece of code which may sleep/wait, and re-acquire it after the sleep/
- wait.
+ Immediately after acquiring the virDomainObjPtr lock, any method
+ which intends to update state must acquire the job condition. The
+ virDomainObjPtr lock is released while blocking on this condition
+ variable. Once the job condition is acquired, a method can safely
+ release the virDomainObjPtr lock whenever it hits a piece of code
+ which may sleep/wait, and re-acquire it after the sleep/wait.
+
+ Since the virDomainObjPtr lock was dropped while waiting for the
+ job condition, it is possible that the domain is no longer active
+ when the condition is finally obtained. The monitor lock is only
+ safe to grab after verifying that the domain is still active.
* qemuMonitorPtr: Mutex
@@ -110,13 +115,15 @@ To acquire the job mutex
qemuDomainObjBeginJob() (if driver is unlocked)
- Increments ref count on virDomainObjPtr
- - Wait qemuDomainObjPrivate condition 'jobActive != 0' using virDomainObjPtr mutex
+ - Wait qemuDomainObjPrivate condition 'jobActive != 0' using
+ virDomainObjPtr mutex
- Sets jobActive to 1
qemuDomainObjBeginJobWithDriver() (if driver needs to be locked)
- Unlocks driver
- Increments ref count on virDomainObjPtr
- - Wait qemuDomainObjPrivate condition 'jobActive != 0' using virDomainObjPtr mutex
+ - Wait qemuDomainObjPrivate condition 'jobActive != 0' using
+ virDomainObjPtr mutex
- Sets jobActive to 1
- Unlocks virDomainObjPtr
- Locks driver
@@ -140,10 +147,10 @@ To acquire the QEMU monitor lock
- Releases the virDomainObjPtr lock
qemuDomainObjExitMonitor()
- - Acquires the virDomainObjPtr lock
- Releases the qemuMonitorObjPtr lock
+ - Acquires the virDomainObjPtr lock
- NB: caller must take care to drop the driver lock if neccessary
+ NB: caller must take care to drop the driver lock if necessary
To acquire the QEMU monitor lock with the driver lock held
@@ -154,11 +161,25 @@ To acquire the QEMU monitor lock with the driver lock held
- Releases the driver lock
qemuDomainObjExitMonitorWithDriver()
+ - Releases the qemuMonitorObjPtr lock
- Acquires the driver lock
- Acquires the virDomainObjPtr lock
- - Releases the qemuMonitorObjPtr lock
- NB: caller must take care to drop the driver lock if neccessary
+ NB: caller must take care to drop the driver lock if necessary
+
+
+To keep a domain alive while waiting on a remote command, starting
+with the driver lock held
+
+ qemuDomainObjEnterRemoterWithDriver()
+ - Increments ref count on virDomainObjPtr
+ - Releases the virDomainObjPtr lock
+ - Releases the driver lock
+
+ qemuDomainObjExitRemoteWithDriver()
+ - Acquires the driver lock
+ - Acquires the virDomainObjPtr lock
+ - Decrements ref count on virDomainObjPtr
Design patterns
@@ -236,9 +257,11 @@ Design patterns
...do prep work...
- qemuDomainObjEnterMonitor(obj);
- qemuMonitorXXXX(priv->mon);
- qemuDomainObjExitMonitor(obj);
+ if (virDomainObjIsActive(vm)) {
+ qemuDomainObjEnterMonitor(obj);
+ qemuMonitorXXXX(priv->mon);
+ qemuDomainObjExitMonitor(obj);
+ }
...do final work...
@@ -261,9 +284,11 @@ Design patterns
...do prep work...
- qemuDomainObjEnterMonitorWithDriver(driver, obj);
- qemuMonitorXXXX(priv->mon);
- qemuDomainObjExitMonitorWithDriver(driver, obj);
+ if (virDomainObjIsActive(vm)) {
+ qemuDomainObjEnterMonitorWithDriver(driver, obj);
+ qemuMonitorXXXX(priv->mon);
+ qemuDomainObjExitMonitorWithDriver(driver, obj);
+ }
...do final work...
@@ -272,6 +297,35 @@ Design patterns
qemuDriverUnlock(driver);
+ * Coordinating with a remote server for migraion
+
+ virDomainObjPtr obj;
+ qemuDomainObjPrivatePtr priv;
+
+ qemuDriverLock(driver);
+ obj = virDomainFindByUUID(driver->domains, dom->uuid);
+
+ qemuDomainObjBeginJobWithDriver(obj);
+
+ ...do prep work...
+
+ if (virDomainObjIsActive(vm)) {
+ qemuDomainObjEnterRemoteWithDriver(driver, obj);
+ ...communicate with remote...
+ qemuDomainObjExitRemoteWithDriver(driver, obj);
+ /* domain may have been stopped while we were talking to remote */
+ if (!virDomainObjIsActive(vm)) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("guest unexpectedly quit"));
+ }
+ }
+
+ ...do final work...
+
+ qemuDomainObjEndJob(obj);
+ virDomainObjUnlock(obj);
+ qemuDriverUnlock(driver);
+
Summary
-------
--
1.7.3.5
13 years, 9 months
[libvirt] Strange nodedev-dumpxml ??
by arnaud.champion@devatom.fr
?Hi,
I have maybe a strange thing on a nodedev-dumpxml virsh result :
virsh # nodedev-dumpxml block_sr0
<device>
<name>block_sr0</name>
<parent>scsi_0_0_1_0</parent>
<capability type='storage'>
<block>/dev/sr0</block>
<bus>scsi</bus>
<drive_type>cdrom</drive_type>
<model>DVD RW DRU-190S</model>
<vendor>SONY</vendor>
<capability type='removable'>
<media_available>0</media_available>
<media_size>0</media_size>
</capability>
</capability>
</device>
I think (note I'm not sure), the capabilty type removable should be in the device element, like this :
virsh # nodedev-dumpxml block_sr0
<device>
<name>block_sr0</name>
<parent>scsi_0_0_1_0</parent>
<capability type='storage'>
<block>/dev/sr0</block>
<bus>scsi</bus>
<drive_type>cdrom</drive_type>
<model>DVD RW DRU-190S</model>
<vendor>SONY</vendor>
</capability>
<capability type='removable'>
<media_available>0</media_available>
<media_size>0</media_size>
</capability>
</device>
Let me know if I'm wrong.
Regards,
Arnaud
13 years, 9 months