[libvirt] [PATCHv2] qemu: agent: Fix QEMU guest agent is not available due to an error
by Xiubo Li
These days, we experienced one qemu guest agent is not available
error. Then the guest agent couldn't be used forever before rebooting
the libvirtd daemon or reboot the qemu-guest-agent in the VM(you can
also reboot the VM) to clear the priv->agentError.
This is one bug for a long time in many verisons of libvirtd:
https://bugzilla.redhat.com/show_bug.cgi?id=1090551
And there is one python script to reproduce this bug from the bugzilla:
https://github.com/aspirer/study/blob/master/qemu-guest-agent/test2.py
Just set the timeout to 0 at Line26, you can reproduce it very quickly:
rsp = libvirt_qemu.qemuAgentCommand(dom, cmd, 1, 0) // 1 -> 0
The reason why this could happen is that:
In case we received something like {"return": {}} for example, it is
likely that somebody:
1) Started GA thread which sent one "guest-ping" command with seconds
equals to VIR_DOMAIN_QEMU_AGENT_COMMAND_NOWAIT(0) makes this function
return immediately without waiting, but after updating the events, it
will sleep in virCondWait() or virCondWaitUntil().
2) While in AgentIO thread the "guest-ping" command is sent successfully,
with updating the events it will wait for reply.
3) Then the GA thread is woken up and the mon->msg is set to NULL and exit.
4) At last the AgentIO thread receives the reply of "guest-ping" command
with the mon->msg == NULL.
This case could be adapt to all the GA commands, including guest-sync, etc.
This patch will check if this is the case and don't report an error but
return silently.
Signed-off-by: Xiubo Li <lixiubo(a)cmss.chinamobile.com>
Signed-off-by: Zhuoyu Zhang <zhangzhuoyu(a)cmss.chinamobile.com>
Signed-off-by: Wei Tang <tangwei(a)cmss.chinamobile.com>
Signed-off-by: Yaowei Bai <baiyaowei(a)cmss.chinamobile.com>
Signed-off-by: Qide Chen <chenqide(a)cmss.chinamobile.com>
---
Changes in V2:
- check value type instead of object type.
src/qemu/qemu_agent.c | 37 ++++++++++++++++++++++++++++---------
src/util/virjson.h | 7 +++++++
2 files changed, 35 insertions(+), 9 deletions(-)
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index eeede6b..f5408cc 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -308,7 +308,6 @@ qemuAgentIOProcessLine(qemuAgentPtr mon,
{
virJSONValuePtr obj = NULL;
int ret = -1;
- unsigned long long id;
VIR_DEBUG("Line [%s]", line);
@@ -333,16 +332,36 @@ qemuAgentIOProcessLine(qemuAgentPtr mon,
obj = NULL;
ret = 0;
} else {
- /* If we've received something like:
- * {"return": 1234}
- * it is likely that somebody started GA
- * which is now processing our previous
- * guest-sync commands. Check if this is
- * the case and don't report an error but
+ virJSONValuePtr val;
+
+ /* In case we received something like:
+ * {"return": {}} for example,
+ * it is likely that somebody:
+ *
+ * 1) Started GA thread which sent one "guest-ping" command
+ * with seconds equals to VIR_DOMAIN_QEMU_AGENT_COMMAND_NOWAIT(0)
+ * makes this function return immediately without waiting, but
+ * after updating the events, it will sleep in virCondWait() or
+ * virCondWaitUntil().
+ *
+ * 2) While in AgentIO thread the "guest-ping" command is sent
+ * successfully, with updating the events it will wait for reply.
+ *
+ * 3) Then the GA thread is woken up and the mon->msg is set
+ * to NULL and exit.
+ *
+ * 4) At last the AgentIO thread receives the reply of "guest-ping"
+ * command with the mon->msg == NULL.
+ *
+ * This case could be adapt to all the GA commands, including
+ * guest-sync, etc.
+ *
+ * Check if this is the case and don't report an error but
* return silently.
*/
- if (virJSONValueObjectGetNumberUlong(obj, "return", &id) == 0) {
- VIR_DEBUG("Ignoring delayed reply to guest-sync: %llu", id);
+ val = virJSONValueObjectGet(obj, "return");
+ if (val && virJSONValueTypeIsValid(val)) {
+ VIR_DEBUG("Ignoring delayed command reply");
ret = 0;
goto cleanup;
}
diff --git a/src/util/virjson.h b/src/util/virjson.h
index 66ed48a..cb1d973 100644
--- a/src/util/virjson.h
+++ b/src/util/virjson.h
@@ -80,6 +80,13 @@ struct _virJSONValue {
} data;
};
+static inline bool
+virJSONValueTypeIsValid(virJSONValuePtr value)
+{
+ return ((value->type >= VIR_JSON_TYPE_OBJECT) &&
+ (value->type <= VIR_JSON_TYPE_BOOLEAN));
+}
+
void virJSONValueFree(virJSONValuePtr value);
int virJSONValueObjectCreate(virJSONValuePtr *obj, ...)
--
1.8.3.1
8 years, 7 months
[libvirt] [PATCH] libxl: support VIR_MIGRATE_PERSIST_DEST migration flag
by Jim Fehlig
By default, virt-manager (and likely other libvirt-based apps) sets
the VIR_MIGRATE_PERSIST_DEST flag when invoking the migrate API, which
fails in a Xen setup since the libxl driver does not support the flag.
Persisting a domain is a trivial task in the grand scheme of migration,
so be nice to libvirt apps and add support for VIR_MIGRATE_PERSIST_DEST
in the libxl driver.
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
src/libxl/libxl_migration.c | 23 +++++++++++++++++++++++
src/libxl/libxl_migration.h | 1 +
2 files changed, 24 insertions(+)
diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c
index f1da251..3b0dc74 100644
--- a/src/libxl/libxl_migration.c
+++ b/src/libxl/libxl_migration.c
@@ -1021,6 +1021,29 @@ libxlDomainMigrationFinish(virConnectPtr dconn,
event = NULL;
}
+ if (flags & VIR_MIGRATE_PERSIST_DEST) {
+ unsigned int oldPersist = vm->persistent;
+ virDomainDefPtr vmdef;
+
+ vm->persistent = 1;
+ if (!(vmdef = virDomainObjGetPersistentDef(cfg->caps,
+ driver->xmlopt, vm)))
+ goto cleanup;
+
+ if (virDomainSaveConfig(cfg->configDir, cfg->caps, vmdef) < 0)
+ goto cleanup;
+
+ event = virDomainEventLifecycleNewFromObj(vm,
+ VIR_DOMAIN_EVENT_DEFINED,
+ oldPersist ?
+ VIR_DOMAIN_EVENT_DEFINED_UPDATED :
+ VIR_DOMAIN_EVENT_DEFINED_ADDED);
+ if (event) {
+ libxlDomainEventQueue(driver, event);
+ event = NULL;
+ }
+ }
+
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, cfg->caps) < 0)
goto cleanup;
diff --git a/src/libxl/libxl_migration.h b/src/libxl/libxl_migration.h
index c02026d..8a074a0 100644
--- a/src/libxl/libxl_migration.h
+++ b/src/libxl/libxl_migration.h
@@ -29,6 +29,7 @@
# define LIBXL_MIGRATION_FLAGS \
(VIR_MIGRATE_LIVE | \
VIR_MIGRATE_PEER2PEER | \
+ VIR_MIGRATE_PERSIST_DEST | \
VIR_MIGRATE_UNDEFINE_SOURCE | \
VIR_MIGRATE_PAUSED)
--
2.1.4
8 years, 7 months
[libvirt] [PATCH] qemu_process: show shutoff reasons when debug log disabled
by Chen Hanxiao
From: Chen Hanxiao <chenhanxiao(a)gmail.com>
We have a few of senarios that libvirtd would invoke qemuProcessStop
and leave a "shutting down" in /var/log/libvirt/qemu/$DOMAIN.log.
The shutoff reason showing in debug log is also very important
for us to know why VM shutting down in domain log,
as we seldom enable debug log of libvirtd.
Signed-off-by: Chen Hanxiao <chenhanxiao(a)gmail.com>
---
src/qemu/qemu_process.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index b10b053..73e9271 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5803,7 +5803,9 @@ void qemuProcessStop(virQEMUDriverPtr driver,
virDomainObjBroadcast(vm);
if ((timestamp = virTimeStringNow()) != NULL) {
- qemuDomainLogAppendMessage(driver, vm, "%s: shutting down\n", timestamp);
+ qemuDomainLogAppendMessage(driver, vm, "%s: shutting down, reason=%s\n",
+ timestamp,
+ virDomainShutoffReasonTypeToString(reason));
VIR_FREE(timestamp);
}
--
1.8.3.1
8 years, 7 months
[libvirt] [PATCH] qemu_process: move graphics validation into separate function
by Pavel Hrdina
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/qemu/qemu_process.c | 56 +++++++++++++++++++++++++++++--------------------
1 file changed, 33 insertions(+), 23 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 1f56883..b360f6b 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4409,6 +4409,38 @@ qemuProcessStartWarnShmem(virDomainObjPtr vm)
}
}
+
+static int
+qemuProcessStartValidateGraphics(virDomainObjPtr vm)
+{
+ size_t i;
+
+ for (i = 0; i < vm->def->ngraphics; i++) {
+ virDomainGraphicsDefPtr graphics = vm->def->graphics[i];
+
+ switch (graphics->type) {
+ case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
+ case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
+ if (graphics->nListens > 1) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("QEMU does not support multiple listens for "
+ "one graphics device."));
+ return -1;
+ }
+ break;
+
+ case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
+ case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
+ case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
+ case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
+ break;
+ }
+ }
+
+ return 0;
+}
+
+
static int
qemuProcessStartValidateXML(virQEMUDriverPtr driver,
virDomainObjPtr vm,
@@ -4456,8 +4488,6 @@ qemuProcessStartValidate(virQEMUDriverPtr driver,
virCapsPtr caps,
unsigned int flags)
{
- size_t i;
-
if (!(flags & VIR_QEMU_PROCESS_START_PRETEND)) {
if (vm->def->virtType == VIR_DOMAIN_VIRT_KVM) {
VIR_DEBUG("Checking for KVM availability");
@@ -4484,27 +4514,7 @@ qemuProcessStartValidate(virQEMUDriverPtr driver,
qemuProcessStartWarnShmem(vm);
- for (i = 0; i < vm->def->ngraphics; i++) {
- virDomainGraphicsDefPtr graphics = vm->def->graphics[i];
-
- switch (graphics->type) {
- case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
- case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
- if (graphics->nListens > 1) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("QEMU does not support multiple listens for "
- "one graphics device."));
- return -1;
- }
- break;
-
- case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
- case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
- case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
- case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
- break;
- }
- }
+ qemuProcessStartValidateGraphics(vm);
return 0;
}
--
2.10.0
8 years, 7 months
[libvirt] [PATCH 0/2] bhyve: add e1000 nic support
by Roman Bogorodskiy
Fabian Freyer (1):
bhyve: Separate out checks from virBhyveProbeCaps
Roman Bogorodskiy (1):
bhyve: add e1000 nic support
src/bhyve/bhyve_capabilities.c | 58 ++++++++++++++++++----
src/bhyve/bhyve_capabilities.h | 1 +
src/bhyve/bhyve_command.c | 32 ++++++++++--
.../bhyvexml2argvdata/bhyvexml2argv-net-e1000.args | 9 ++++
.../bhyvexml2argv-net-e1000.ldargs | 3 ++
.../bhyvexml2argvdata/bhyvexml2argv-net-e1000.xml | 22 ++++++++
tests/bhyvexml2argvtest.c | 7 ++-
7 files changed, 118 insertions(+), 14 deletions(-)
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-net-e1000.args
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-net-e1000.ldargs
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-net-e1000.xml
--
2.9.2
8 years, 7 months
[libvirt] [PATCH] libvirt-nodedev.c:fix a typo
by Nitesh Konkar
Signed-off-by: Nitesh Konkar <nitkon12(a)linux.vnet.ibm.com>
---
src/libvirt-nodedev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/libvirt-nodedev.c b/src/libvirt-nodedev.c
index e4e9836..59f020b 100644
--- a/src/libvirt-nodedev.c
+++ b/src/libvirt-nodedev.c
@@ -595,7 +595,7 @@ virNodeDeviceDetachFlags(virNodeDevicePtr dev,
* virNodeDeviceReAttach:
* @dev: pointer to the node device
*
- * Re-attach a previously dettached node device to the node so that it
+ * Re-attach a previously detached node device to the node so that it
* may be used by the node again.
*
* Depending on the hypervisor, this may involve operations such
--
2.1.0
8 years, 7 months
[libvirt] [PATCH] libvirt-admin.c:fix a typo
by Nitesh Konkar
Signed-off-by: Nitesh Konkar <nitkon12(a)linux.vnet.ibm.com>
---
src/libvirt-admin.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/libvirt-admin.c b/src/libvirt-admin.c
index 03245b6..88eef54 100644
--- a/src/libvirt-admin.c
+++ b/src/libvirt-admin.c
@@ -344,7 +344,7 @@ virAdmConnectRef(virAdmConnectPtr conn)
* @libVer: where to store the library version
*
* Provides version information. @libVer is the version of the library and will
- * allways be set unless an error occurs in which case an error code and a
+ * always be set unless an error occurs in which case an error code and a
* generic message will be returned. @libVer format is as follows:
* major * 1,000,000 + minor * 1,000 + release.
*
--
2.1.0
8 years, 7 months
[libvirt] [PATCH] domain_conf.c:fix a typo
by Nitesh Konkar
Signed-off-by: Nitesh Konkar <nitkon12(a)linux.vnet.ibm.com>
---
src/conf/domain_conf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index ea246b0..28b81d2 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -25447,7 +25447,7 @@ virDomainDiskDefCheckDuplicateInfo(const virDomainDiskDef *a,
}
/* Duplicate WWN/serial isn't usually problematic for the OS and
- * forbiding it would possibly inhibit using multipath configurations */
+ * forbidding it would possibly inhibit using multipath configurations */
return 0;
}
--
2.1.0
8 years, 7 months
[libvirt] [PATCH] driver.c:fix a typo
by Nitesh Konkar
Signed-off-by: Nitesh Konkar <nitkon12(a)linux.vnet.ibm.com>
---
src/driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/driver.c b/src/driver.c
index 1514a3b..67ac020 100644
--- a/src/driver.c
+++ b/src/driver.c
@@ -38,7 +38,7 @@ VIR_LOG_INIT("driver");
#ifdef WITH_DRIVER_MODULES
-/* XXX re-implment this for other OS, or use libtools helper lib ? */
+/* XXX re-implement this for other OS, or use libtools helper lib ? */
# include <dlfcn.h>
# define DEFAULT_DRIVER_DIR LIBDIR "/libvirt/connection-driver"
--
2.1.0
8 years, 7 months
[libvirt] [PATCH] domain_conf.c:fix the comment.
by Nitesh Konkar
Signed-off-by: Nitesh Konkar <nitkon12(a)linux.vnet.ibm.com>
---
src/conf/domain_conf.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index ebddf5f..7daf2fd 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -14091,9 +14091,9 @@ void
virDomainNetRemoveHostdev(virDomainDefPtr def,
virDomainNetDefPtr net)
{
- /* hostdev net devices are normally also be in the hostdevs
- * array, but might have already been removed by the time we
- * get here.
+ /* hostdev net devices are normally in the hostdevs
+ * array, but might have already been removed by the
+ * time we get here.
*/
virDomainHostdevDefPtr hostdev = virDomainNetGetActualHostdev(net);
size_t i;
--
2.1.0
8 years, 7 months