[libvirt] [PATCH 0/3] Update rebootTimeout range to 0..0xffff
by Han Han
Since qemu v4.0.0(commit ee5d0f89de3), reboot-timeout valid range was
set 0~0xffff. Update libvirt codes, docs, tests for that change.
I am not sure if po files should be updated. If so, please point it out.
Han Han (3):
conf: Set rebootTimeout valid range to 0..0xffff
tests: Remove test reboot-timeout-disabled
docs: Update docs on rebootTimeout valid value range
docs/formatdomain.html.in | 5 ++--
src/conf/domain_conf.c | 6 ++--
.../reboot-timeout-disabled.args | 28 -------------------
.../reboot-timeout-disabled.xml | 24 ----------------
.../reboot-timeout-disabled.xml | 26 -----------------
5 files changed, 6 insertions(+), 83 deletions(-)
delete mode 100644 tests/qemuxml2argvdata/reboot-timeout-disabled.args
delete mode 100644 tests/qemuxml2argvdata/reboot-timeout-disabled.xml
delete mode 100644 tests/qemuxml2xmloutdata/reboot-timeout-disabled.xml
--
2.20.1
5 years, 1 month
[libvirt] [PATCH Rust v2] api_tests.py: update to use Python 3
by liushuyu
From: Zixing Liu <liushuyu011(a)gmail.com>
Signed-off-by: Zixing Liu <liushuyu011(a)gmail.com>
---
tools/api_tests.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/api_tests.py b/tools/api_tests.py
index b26ec34..9e66c92 100644
--- a/tools/api_tests.py
+++ b/tools/api_tests.py
@@ -47,10 +47,10 @@ def main():
else:
missing.add(el)
- print "missing: %s, implemented: %s" % (len(missing), len(implemented))
- print "missing:"
+ print("missing: %s, implemented: %s" % (len(missing), len(implemented)))
+ print("missing:")
for x in missing:
- print x.attrib
+ print(x.attrib)
#print "implemented:"
#for x in implemented:
# print x.attrib
--
2.24.0
5 years, 1 month
[libvirt] [PATCH Rust] api_tests.py: update to use Python 3
by liushuyu
From: liushuyu <liushuyu011(a)gmail.com>
---
tools/api_tests.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/api_tests.py b/tools/api_tests.py
index b26ec34..9e66c92 100644
--- a/tools/api_tests.py
+++ b/tools/api_tests.py
@@ -47,10 +47,10 @@ def main():
else:
missing.add(el)
- print "missing: %s, implemented: %s" % (len(missing), len(implemented))
- print "missing:"
+ print("missing: %s, implemented: %s" % (len(missing), len(implemented)))
+ print("missing:")
for x in missing:
- print x.attrib
+ print(x.attrib)
#print "implemented:"
#for x in implemented:
# print x.attrib
--
2.23.0
5 years, 1 month
[libvirt] [PATCH] qemu: hotplug: ensure address generation for vfio-ccw
by Bjoern Walk
When attaching a mediated host device of model vfio-ccw without
specifying a guest-address, none is generated by libvirt. Let's fix this
and make sure to generate a device address during live-hotplug.
Reviewed-by: Boris Fiuczynski <fiuczy(a)linux.ibm.com>
Signed-off-by: Bjoern Walk <bwalk(a)linux.ibm.com>
---
src/qemu/qemu_hotplug.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index fd4bafef..7b775159 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -2790,6 +2790,8 @@ qemuDomainAttachMediatedDevice(virQEMUDriverPtr driver,
{
int ret = -1;
g_autofree char *devstr = NULL;
+ char *devName = NULL;
+ bool releaseaddr = false;
bool added = false;
bool teardowncgroup = false;
bool teardownlabel = false;
@@ -2805,6 +2807,10 @@ qemuDomainAttachMediatedDevice(virQEMUDriverPtr driver,
return -1;
break;
case VIR_MDEV_MODEL_TYPE_VFIO_CCW:
+ devName = hostdev->source.subsys.u.mdev.uuidstr;
+ if (qemuDomainEnsureVirtioAddress(&releaseaddr, vm, &dev, devName) < 0)
+ return -1;
+ break;
case VIR_MDEV_MODEL_TYPE_LAST:
break;
}
--
2.21.0
5 years, 1 month
[libvirt] [PATCH v1 00/21] remove 'cleanup: return' labels
by Daniel Henrique Barboza
Hi,
This series is focused on removing most of the unused 'cleanup'
labels that we have in the code so far (as of master commit
2cff65e4c6). I say 'most' because there's a handful of instances
left that are being used by macros and other machinery that
I judged it wasn't worth to deal with in the scope of this work.
The motivations for this change are (1) less code to deal with and
(2) a bit more clarity, since the presence of a 'cleanup' label should
indicate a cleanup procedure (virObjectUnref and so on).
The vast majority of the cases being handled here are variations
of the following pattern:
-----
(function header)
int ret = -1;
( nothing is done with 'ret' in the function body,
'cleanup' calls are made on error conditions)
ret = 0;
cleanup:
return ret;
(end of function)
-----
This pattern can be replaced by removing 'cleanup:' and 'ret',
replacing it with 'return -1' on error conditions and 'return 0'
on success. Other patterns were handled as well, but this is the
most frequent one.
I made an effort to *not* change or refactor the function logic in
the attempt of removing labels.
Patches were split by directory. If only one file in a dir got
changed, the file is mentioned in the commit instead.
There were not preparatory patches for these changes because they
are intended to be somewhat simple. The one exception is patch 09.
I chose to handle that case in a separated patch to not clutter the
review of patch 10, but I expect it to be merged with the 'qemu'
patch once it is reviewed.
All these changes are available in [1].
[1] https://github.com/danielhb/libvirt/tree/clean_trivial_labels
Daniel Henrique Barboza (21):
conf: remove unneeded cleanup labels
storage: remove unneeded cleanup labels
nwfilter: remove unneeded cleanup labels
remote: remove unneeded cleanup labels
lxc: remove unneeded cleanup labels
node_device: remove unneeded cleanup labels
secret_driver.c: remove unneeded cleanup label
openvz_conf.c: remove unneeded cleanup label
qemu_monitor_json.c: remove unneeded cleanup label
qemu: remove unneeded cleanup labels
rpc: remove unneeded cleanup labels
vz_sdk.c: remove unneeded cleanup label
vbox: remove unneeded cleanup labels
util: remove unneeded cleanup labels
libvirt.c: remove unneeded cleanup label
libxl_driver.c: remove unneeded cleanup label
bridge_driver.c: remove unneeded cleanup labels
suspend.c: remove unneeded cleanup label
tools: remove unneeded cleanup labels
tests: remove unneeded cleanup labels
bhyve_device.c: remove unneeded cleanup labels
examples/c/domain/suspend.c | 9 +-
src/bhyve/bhyve_device.c | 18 +-
src/conf/domain_addr.c | 23 +-
src/conf/domain_capabilities.c | 21 +-
src/conf/domain_conf.c | 334 ++++++++--------------
src/conf/netdev_bandwidth_conf.c | 17 +-
src/conf/network_conf.c | 25 +-
src/conf/node_device_conf.c | 28 +-
src/conf/numa_conf.c | 25 +-
src/conf/nwfilter_conf.c | 4 +-
src/conf/storage_conf.c | 7 +-
src/conf/virnetworkobj.c | 14 +-
src/conf/virsecretobj.c | 5 +-
src/libvirt.c | 7 +-
src/libxl/libxl_driver.c | 16 +-
src/lxc/lxc_cgroup.c | 70 ++---
src/lxc/lxc_container.c | 17 +-
src/lxc/lxc_controller.c | 44 ++-
src/lxc/lxc_driver.c | 39 +--
src/lxc/lxc_process.c | 34 +--
src/network/bridge_driver.c | 172 +++++------
src/node_device/node_device_driver.c | 11 +-
src/node_device/node_device_udev.c | 8 +-
src/nwfilter/nwfilter_ebiptables_driver.c | 132 ++++-----
src/openvz/openvz_conf.c | 3 +-
src/qemu/qemu_cgroup.c | 15 +-
src/qemu/qemu_domain.c | 92 +++---
src/qemu/qemu_domain_address.c | 31 +-
src/qemu/qemu_driver.c | 140 ++++-----
src/qemu/qemu_hotplug.c | 45 ++-
src/qemu/qemu_interface.c | 26 +-
src/qemu/qemu_migration.c | 38 +--
src/qemu/qemu_monitor_json.c | 15 +-
src/qemu/qemu_process.c | 77 ++---
src/qemu/qemu_tpm.c | 20 +-
src/remote/remote_daemon.c | 38 ++-
src/remote/remote_driver.c | 15 +-
src/rpc/virnetserver.c | 15 +-
src/rpc/virnetserverprogram.c | 13 +-
src/rpc/virnetsocket.c | 9 +-
src/rpc/virnettlscontext.c | 20 +-
src/secret/secret_driver.c | 11 +-
src/storage/storage_backend_fs.c | 13 +-
src/storage/storage_backend_rbd.c | 58 ++--
src/storage/storage_backend_zfs.c | 21 +-
src/storage/storage_driver.c | 38 +--
src/storage/storage_util.c | 18 +-
src/util/vircgroupv1.c | 18 +-
src/util/vircommand.c | 11 +-
src/util/virdbus.c | 30 +-
src/util/virfile.c | 19 +-
src/util/virhash.c | 6 +-
src/util/virhostcpu.c | 20 +-
src/util/virhostdev.c | 7 +-
src/util/virhostmem.c | 55 ++--
src/util/virjson.c | 30 +-
src/util/virmacmap.c | 10 +-
src/util/virnetdevbridge.c | 21 +-
src/util/virnuma.c | 27 +-
src/util/virpci.c | 7 +-
src/util/virprocess.c | 19 +-
src/util/virresctrl.c | 7 +-
src/util/virstoragefile.c | 46 +--
src/util/virutil.c | 19 +-
src/vbox/vbox_common.c | 12 +-
src/vbox/vbox_snapshot_conf.c | 75 ++---
src/vz/vz_sdk.c | 8 +-
tests/commandtest.c | 17 +-
tests/domainconftest.c | 5 +-
tests/networkxml2firewalltest.c | 13 +-
tests/nsstest.c | 27 +-
tests/nwfilterebiptablestest.c | 4 +-
tests/nwfilterxml2firewalltest.c | 16 +-
tests/qemuhotplugtest.c | 19 +-
tests/qemuxml2argvtest.c | 11 +-
tests/storagebackendsheepdogtest.c | 5 +-
tests/virauthconfigtest.c | 11 +-
tests/vircgroupmock.c | 11 +-
tests/virendiantest.c | 58 ++--
tests/virkeycodetest.c | 14 +-
tests/virmacmaptest.c | 5 +-
tests/virnetdevtest.c | 11 +-
tests/virpcimock.c | 31 +-
tests/virpcitest.c | 3 +-
tests/virpolkittest.c | 65 ++---
tests/virstringtest.c | 18 +-
tools/virsh-completer-network.c | 8 +-
tools/virsh-domain.c | 41 +--
tools/vsh.c | 14 +-
89 files changed, 983 insertions(+), 1722 deletions(-)
--
2.21.0
5 years, 1 month
[libvirt] [PATCH 0/7] util: buffer: Simplify child buffer init
by Peter Krempa
This applies on top of
https://www.redhat.com/archives/libvir-list/2019-November/msg00397.html
Peter Krempa (7):
util: buffer: Add init macro for automatically setting child XML
indent
qemu: domain: Convert child buffers to use VIR_BUFFER_INIT_CHILD
util: sysinfo: Convert child buffers to use VIR_BUFFER_INIT_CHILD
conf: caps: sysinfo: Convert child buffers to use
VIR_BUFFER_INIT_CHILD
conf: cpu: Convert child buffers to use VIR_BUFFER_INIT_CHILD
conf: domain: Convert child buffers to use VIR_BUFFER_INIT_CHILD
util: buffer: remove virBufferSetChildIndent
src/conf/capabilities.c | 13 ++----
src/conf/cpu_conf.c | 3 +-
src/conf/domain_conf.c | 101 +++++++++++-----------------------------
src/qemu/qemu_domain.c | 35 ++++----------
src/util/virbuffer.h | 18 +++----
src/util/virsysinfo.c | 4 +-
6 files changed, 52 insertions(+), 122 deletions(-)
--
2.23.0
5 years, 1 month
[libvirt] [PATCH 0/3] capabilities: Sanitize handling of 'features'
by Peter Krempa
Peter Krempa (3):
schema: capabilities: Add 'hap' feature flag
conf: Refactor storage of guest capabilities
conf: capabilities: Refactor API for setting guest capability features
docs/schemas/capability.rng | 6 +
src/conf/capabilities.c | 149 +++++++++++++--------
src/conf/capabilities.h | 35 +++--
src/libvirt_private.syms | 1 +
src/libxl/libxl_capabilities.c | 46 ++-----
src/qemu/qemu_capabilities.c | 34 ++---
src/test/test_driver.c | 6 +-
tests/qemucaps2xmloutdata/caps.aarch64.xml | 2 +-
tests/qemucaps2xmloutdata/caps.x86_64.xml | 4 +-
tests/testutilsqemu.c | 6 +-
10 files changed, 156 insertions(+), 133 deletions(-)
--
2.23.0
5 years, 1 month
[libvirt] [PATCH v2] Add API to change qemu agent response timeout
by Jonathon Jongsma
Some layered products such as oVirt have requested a way to avoid being
blocked by guest agent commands when querying a loaded vm. For example,
many guest agent commands are polled periodically to monitor changes,
and rather than blocking the calling process, they'd prefer to simply
time out when an agent query is taking too long.
This patch adds a way for the user to specify a custom agent timeout
that is applied to all agent commands.
One special case to note here is the 'guest-sync' command. 'guest-sync'
is issued internally prior to calling any other command. (For example,
when libvirt wants to call 'guest-get-fsinfo', we first call
'guest-sync' and then call 'guest-get-fsinfo').
Previously, the 'guest-sync' command used a 5-second timeout
(VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT), whereas the actual command that
followed always blocked indefinitely
(VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK). As part of this patch, if a
custom timeout is specified that is shorter than
5 seconds, this new timeout is also used for 'guest-sync'. If there is
no custom timeout or if the custom timeout is longer than 5 seconds, we
will continue to use the 5-second timeout.
See https://bugzilla.redhat.com/show_bug.cgi?id=1705426 for additional details.
Signed-off-by: Jonathon Jongsma <jjongsma(a)redhat.com>
---
I've addressed most of the previous review comments from Peter, Daniel, and
Michal but I'm unsure yet whether there's concensus on this feature. Here's a
v2 for your consideration.
I admit that the proposed API is not perfect. It would probably be more elegant
if each agent command instead had its own 'timeout' argument so that the caller
could specify the timeout for each invocation. But that is not the case, and
introducing duplicate API for each agent command (with an additional timeout
argument) would clutter the public API. In addition, we still have the issue
Michal mentioned elsewhere in the thread where some commands like shutdown may
or may not use the agent, so a timeout argument could be confusing.
So: is this a viable approach, or should I rethink it?
Changes in v2:
- Make this an official public API rather than putting it in libvirt-qemu.
- Don't use the qemuDomainObjEnterAgent()/ExitAgent() API, which expects you
to acquire an agent job. Instead, introduce
qemuDomainObjSetAgentResponseTimeout() which simply locks the agent while
setting the variable.
- rename the function slightly for better descriptiveness:
virDomainQemuAgentSetTimeout() -> virDomainAgentSetResponseTimeout()
- added 'flags' argument for future-proofing.
include/libvirt/libvirt-domain.h | 9 ++++
include/libvirt/libvirt-qemu.h | 8 +--
src/driver-hypervisor.h | 6 +++
src/libvirt-domain.c | 45 +++++++++++++++++
src/libvirt_public.syms | 1 +
src/qemu/qemu_agent.c | 84 ++++++++++++++++++++------------
src/qemu/qemu_agent.h | 4 ++
src/qemu/qemu_domain.c | 15 ++++++
src/qemu/qemu_domain.h | 5 ++
src/qemu/qemu_driver.c | 22 +++++++++
src/remote/remote_driver.c | 1 +
src/remote/remote_protocol.x | 18 ++++++-
src/remote_protocol-structs | 9 ++++
13 files changed, 190 insertions(+), 37 deletions(-)
diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 22277b0a84..83f6c1b835 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -4916,4 +4916,13 @@ int virDomainGetGuestInfo(virDomainPtr domain,
int *nparams,
unsigned int flags);
+typedef enum {
+ VIR_DOMAIN_AGENT_COMMAND_BLOCK = -2,
+ VIR_DOMAIN_AGENT_COMMAND_DEFAULT = -1,
+ VIR_DOMAIN_AGENT_COMMAND_NOWAIT = 0,
+} virDomainAgentCommandTimeoutValues;
+int virDomainAgentSetResponseTimeout(virDomainPtr domain,
+ int timeout,
+ unsigned int flags);
+
#endif /* LIBVIRT_DOMAIN_H */
diff --git a/include/libvirt/libvirt-qemu.h b/include/libvirt/libvirt-qemu.h
index 891617443f..4a541167ad 100644
--- a/include/libvirt/libvirt-qemu.h
+++ b/include/libvirt/libvirt-qemu.h
@@ -43,10 +43,10 @@ virDomainPtr virDomainQemuAttach(virConnectPtr domain,
unsigned int flags);
typedef enum {
- VIR_DOMAIN_QEMU_AGENT_COMMAND_MIN = -2,
- VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK = -2,
- VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT = -1,
- VIR_DOMAIN_QEMU_AGENT_COMMAND_NOWAIT = 0,
+ VIR_DOMAIN_QEMU_AGENT_COMMAND_MIN = VIR_DOMAIN_AGENT_COMMAND_BLOCK,
+ VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK = VIR_DOMAIN_AGENT_COMMAND_BLOCK,
+ VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT = VIR_DOMAIN_AGENT_COMMAND_DEFAULT,
+ VIR_DOMAIN_QEMU_AGENT_COMMAND_NOWAIT = VIR_DOMAIN_AGENT_COMMAND_NOWAIT,
VIR_DOMAIN_QEMU_AGENT_COMMAND_SHUTDOWN = 60,
} virDomainQemuAgentCommandTimeoutValues;
diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h
index 015b2cd01c..4afd8f6ec5 100644
--- a/src/driver-hypervisor.h
+++ b/src/driver-hypervisor.h
@@ -1372,6 +1372,11 @@ typedef int
int *nparams,
unsigned int flags);
+typedef int
+(*virDrvDomainAgentSetResponseTimeout)(virDomainPtr domain,
+ int timeout,
+ unsigned int flags);
+
typedef struct _virHypervisorDriver virHypervisorDriver;
typedef virHypervisorDriver *virHypervisorDriverPtr;
@@ -1632,4 +1637,5 @@ struct _virHypervisorDriver {
virDrvDomainCheckpointGetParent domainCheckpointGetParent;
virDrvDomainCheckpointDelete domainCheckpointDelete;
virDrvDomainGetGuestInfo domainGetGuestInfo;
+ virDrvDomainAgentSetResponseTimeout domainAgentSetResponseTimeout;
};
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index dcab179e6e..b4e1b18164 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -12497,3 +12497,48 @@ int virDomainGetLaunchSecurityInfo(virDomainPtr domain,
virDispatchError(domain->conn);
return -1;
}
+
+/**
+ * virDomainAgentSetResponseTimeout:
+ * @domain: a domain object
+ * @timeout: timeout in seconds
+ * @flags: extra flags; not used yet, so callers should always pass 0
+ *
+ * Set how long to wait for a response from qemu agent commands. By default,
+ * agent commands block forever waiting for a response.
+ *
+ * @timeout must be -2, -1, 0 or positive.
+ * VIR_DOMAIN_AGENT_COMMAND_BLOCK(-2): meaning to block forever waiting for a
+ * result.
+ * VIR_DOMAIN_AGENT_COMMAND_DEFAULT(-1): use default timeout value.
+ * VIR_DOMAIN_AGENT_COMMAND_NOWAIT(0): does not wait.
+ * positive value: wait for @timeout seconds
+ *
+ * Returns 0 on success, -1 on failure
+ */
+int
+virDomainAgentSetResponseTimeout(virDomainPtr domain,
+ int timeout,
+ unsigned int flags)
+{
+ virConnectPtr conn;
+ VIR_DOMAIN_DEBUG(domain, "timeout=%i, flags=0x%x",
+ timeout, flags);
+
+ virResetLastError();
+
+ virCheckDomainReturn(domain, -1);
+ conn = domain->conn;
+
+ if (conn->driver->domainAgentSetResponseTimeout) {
+ if (conn->driver->domainAgentSetResponseTimeout(domain, timeout, flags) < 0)
+ goto error;
+ return 0;
+ }
+
+ virReportUnsupportedError();
+
+ error:
+ virDispatchError(conn);
+ return -1;
+}
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 40655fbbf5..74d5e0b4b9 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -859,6 +859,7 @@ LIBVIRT_5.7.0 {
LIBVIRT_5.8.0 {
virConnectSetIdentity;
+ virDomainAgentSetResponseTimeout;
} LIBVIRT_5.7.0;
# .... define new API here using predicted next version number ....
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 4b914e6d3b..c2f9a025ba 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -127,6 +127,7 @@ struct _qemuAgent {
* but fire up an event on qemu monitor instead.
* Take that as indication of successful completion */
qemuAgentEvent await_event;
+ int timeout;
};
static virClassPtr qemuAgentClass;
@@ -695,6 +696,8 @@ qemuAgentOpen(virDomainObjPtr vm,
if (!(mon = virObjectLockableNew(qemuAgentClass)))
return NULL;
+ /* agent commands block by default, user can choose different behavior */
+ mon->timeout = VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK;
mon->fd = -1;
if (virCondInit(&mon->notify) < 0) {
virReportSystemError(errno, "%s",
@@ -907,6 +910,12 @@ qemuAgentGuestSync(qemuAgentPtr mon)
int send_ret;
unsigned long long id;
qemuAgentMessage sync_msg;
+ int timeout = VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT;
+
+ /* if user specified a custom agent timeout that is lower than the
+ * default timeout, use the shorter timeout instead */
+ if ((mon->timeout >= 0) && (mon->timeout < timeout))
+ timeout = mon->timeout;
memset(&sync_msg, 0, sizeof(sync_msg));
/* set only on first sync */
@@ -927,8 +936,7 @@ qemuAgentGuestSync(qemuAgentPtr mon)
VIR_DEBUG("Sending guest-sync command with ID: %llu", id);
- send_ret = qemuAgentSend(mon, &sync_msg,
- VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT);
+ send_ret = qemuAgentSend(mon, &sync_msg, timeout);
VIR_DEBUG("qemuAgentSend returned: %d", send_ret);
@@ -1304,8 +1312,7 @@ int qemuAgentFSFreeze(qemuAgentPtr mon, const char **mountpoints,
if (!cmd)
goto cleanup;
- if (qemuAgentCommand(mon, cmd, &reply, true,
- VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0)
+ if (qemuAgentCommand(mon, cmd, &reply, true, mon->timeout) < 0)
goto cleanup;
if (virJSONValueObjectGetNumberInt(reply, "return", &ret) < 0) {
@@ -1342,8 +1349,7 @@ int qemuAgentFSThaw(qemuAgentPtr mon)
if (!cmd)
return -1;
- if (qemuAgentCommand(mon, cmd, &reply, true,
- VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0)
+ if (qemuAgentCommand(mon, cmd, &reply, true, mon->timeout) < 0)
goto cleanup;
if (virJSONValueObjectGetNumberInt(reply, "return", &ret) < 0) {
@@ -1380,8 +1386,7 @@ qemuAgentSuspend(qemuAgentPtr mon,
return -1;
mon->await_event = QEMU_AGENT_EVENT_SUSPEND;
- ret = qemuAgentCommand(mon, cmd, &reply, false,
- VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK);
+ ret = qemuAgentCommand(mon, cmd, &reply, false, mon->timeout);
virJSONValueFree(cmd);
virJSONValueFree(reply);
@@ -1437,8 +1442,7 @@ qemuAgentFSTrim(qemuAgentPtr mon,
if (!cmd)
return ret;
- ret = qemuAgentCommand(mon, cmd, &reply, false,
- VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK);
+ ret = qemuAgentCommand(mon, cmd, &reply, false, mon->timeout);
virJSONValueFree(cmd);
virJSONValueFree(reply);
@@ -1459,8 +1463,7 @@ qemuAgentGetVCPUs(qemuAgentPtr mon,
if (!(cmd = qemuAgentMakeCommand("guest-get-vcpus", NULL)))
return -1;
- if (qemuAgentCommand(mon, cmd, &reply, true,
- VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0)
+ if (qemuAgentCommand(mon, cmd, &reply, true, mon->timeout) < 0)
goto cleanup;
if (!(data = virJSONValueObjectGetArray(reply, "return"))) {
@@ -1575,8 +1578,7 @@ qemuAgentSetVCPUsCommand(qemuAgentPtr mon,
NULL)))
goto cleanup;
- if (qemuAgentCommand(mon, cmd, &reply, true,
- VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0)
+ if (qemuAgentCommand(mon, cmd, &reply, true, mon->timeout) < 0)
goto cleanup;
/* All negative values are invalid. Return of 0 is bogus since we wouldn't
@@ -1731,8 +1733,7 @@ qemuAgentGetHostname(qemuAgentPtr mon,
if (!cmd)
return ret;
- if (qemuAgentCommand(mon, cmd, &reply, true,
- VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0) {
+ if (qemuAgentCommand(mon, cmd, &reply, true, mon->timeout) < 0) {
if (qemuAgentErrorCommandUnsupported(reply))
ret = -2;
goto cleanup;
@@ -1776,8 +1777,7 @@ qemuAgentGetTime(qemuAgentPtr mon,
if (!cmd)
return ret;
- if (qemuAgentCommand(mon, cmd, &reply, true,
- VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0)
+ if (qemuAgentCommand(mon, cmd, &reply, true, mon->timeout) < 0)
goto cleanup;
if (virJSONValueObjectGetNumberUlong(reply, "return", &json_time) < 0) {
@@ -1842,8 +1842,7 @@ qemuAgentSetTime(qemuAgentPtr mon,
if (!cmd)
return ret;
- if (qemuAgentCommand(mon, cmd, &reply, true,
- VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0)
+ if (qemuAgentCommand(mon, cmd, &reply, true, mon->timeout) < 0)
goto cleanup;
ret = 0;
@@ -2046,8 +2045,7 @@ qemuAgentGetFSInfoInternal(qemuAgentPtr mon,
if (!cmd)
return ret;
- if (qemuAgentCommand(mon, cmd, &reply, true,
- VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0) {
+ if (qemuAgentCommand(mon, cmd, &reply, true, mon->timeout) < 0) {
if (qemuAgentErrorCommandUnsupported(reply))
ret = -2;
goto cleanup;
@@ -2336,8 +2334,7 @@ qemuAgentGetInterfaces(qemuAgentPtr mon,
if (!(cmd = qemuAgentMakeCommand("guest-network-get-interfaces", NULL)))
goto cleanup;
- if (qemuAgentCommand(mon, cmd, &reply, true,
- VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0)
+ if (qemuAgentCommand(mon, cmd, &reply, true, mon->timeout) < 0)
goto cleanup;
if (!(ret_array = virJSONValueObjectGet(reply, "return"))) {
@@ -2514,8 +2511,7 @@ qemuAgentSetUserPassword(qemuAgentPtr mon,
NULL)))
goto cleanup;
- if (qemuAgentCommand(mon, cmd, &reply, true,
- VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0)
+ if (qemuAgentCommand(mon, cmd, &reply, true, mon->timeout) < 0)
goto cleanup;
ret = 0;
@@ -2546,8 +2542,7 @@ qemuAgentGetUsers(qemuAgentPtr mon,
if (!(cmd = qemuAgentMakeCommand("guest-get-users", NULL)))
return -1;
- if (qemuAgentCommand(mon, cmd, &reply, true,
- VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0) {
+ if (qemuAgentCommand(mon, cmd, &reply, true, mon->timeout) < 0) {
if (qemuAgentErrorCommandUnsupported(reply))
return -2;
return -1;
@@ -2636,8 +2631,7 @@ qemuAgentGetOSInfo(qemuAgentPtr mon,
if (!(cmd = qemuAgentMakeCommand("guest-get-osinfo", NULL)))
return -1;
- if (qemuAgentCommand(mon, cmd, &reply, true,
- VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0) {
+ if (qemuAgentCommand(mon, cmd, &reply, true, mon->timeout) < 0) {
if (qemuAgentErrorCommandUnsupported(reply))
return -2;
return -1;
@@ -2692,8 +2686,7 @@ qemuAgentGetTimezone(qemuAgentPtr mon,
if (!(cmd = qemuAgentMakeCommand("guest-get-timezone", NULL)))
return -1;
- if (qemuAgentCommand(mon, cmd, &reply, true,
- VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0) {
+ if (qemuAgentCommand(mon, cmd, &reply, true, mon->timeout) < 0) {
if (qemuAgentErrorCommandUnsupported(reply))
return -2;
return -1;
@@ -2722,3 +2715,30 @@ qemuAgentGetTimezone(qemuAgentPtr mon,
return 0;
}
+
+/* qemuAgentSetResponseTimeout:
+ * mon: agent monitor
+ * timeout: number of seconds to wait for agent response
+ * flags: currently unused. Must pass 0
+ *
+ * the agent object must be locked prior to calling this function
+ *
+ * Returns: 0 on success
+ * -1 otherwise
+ */
+int
+qemuAgentSetResponseTimeout(qemuAgentPtr mon,
+ int timeout,
+ unsigned int flags G_GNUC_UNUSED)
+{
+ if (timeout < VIR_DOMAIN_QEMU_AGENT_COMMAND_MIN) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("guest agent timeout '%d' is "
+ "less than the minimum '%d'"),
+ timeout, VIR_DOMAIN_QEMU_AGENT_COMMAND_MIN);
+ return -1;
+ }
+
+ mon->timeout = timeout;
+ return 0;
+}
diff --git a/src/qemu/qemu_agent.h b/src/qemu/qemu_agent.h
index 78e648992a..88ead4762a 100644
--- a/src/qemu/qemu_agent.h
+++ b/src/qemu/qemu_agent.h
@@ -140,3 +140,7 @@ int qemuAgentGetTimezone(qemuAgentPtr mon,
virTypedParameterPtr *params,
int *nparams,
int *maxparams);
+
+int qemuAgentSetResponseTimeout(qemuAgentPtr mon,
+ int timeout,
+ unsigned int flags);
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 667cc89072..40d0401e79 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -15564,3 +15564,18 @@ qemuDomainSupportsCheckpointsBlockjobs(virDomainObjPtr vm)
return 0;
}
+
+int qemuDomainObjSetAgentResponseTimeout(virDomainObjPtr vm,
+ int timeout,
+ unsigned int flags)
+{
+ qemuDomainObjPrivatePtr priv = vm->privateData;
+ qemuAgentPtr agent = priv->agent;
+ int ret;
+
+ virObjectLock(agent);
+ ret = qemuAgentSetResponseTimeout(agent, timeout, flags);
+ virObjectUnlock(agent);
+
+ return ret;
+}
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index b23912ee98..34af55ef45 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -1225,3 +1225,8 @@ qemuDomainValidateActualNetDef(const virDomainNetDef *net,
int
qemuDomainSupportsCheckpointsBlockjobs(virDomainObjPtr vm)
G_GNUC_WARN_UNUSED_RESULT;
+
+int
+qemuDomainObjSetAgentResponseTimeout(virDomainObjPtr vm,
+ int seconds,
+ unsigned int flags);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d17c18705b..68f7b65d81 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -22654,6 +22654,27 @@ qemuDomainGetGuestInfo(virDomainPtr dom,
return ret;
}
+static int
+qemuDomainAgentSetResponseTimeout(virDomainPtr dom,
+ int timeout,
+ unsigned int flags)
+{
+ virDomainObjPtr vm = NULL;
+ int ret = -1;
+
+ if (!(vm = qemuDomainObjFromDomain(dom)))
+ goto cleanup;
+
+ if (virDomainAgentSetResponseTimeoutEnsureACL(dom->conn, vm->def) < 0)
+ goto cleanup;
+
+ ret = qemuDomainObjSetAgentResponseTimeout(vm, timeout, flags);
+
+ cleanup:
+ virDomainObjEndAPI(&vm);
+ return ret;
+}
+
static virHypervisorDriver qemuHypervisorDriver = {
.name = QEMU_DRIVER_NAME,
.connectURIProbe = qemuConnectURIProbe,
@@ -22890,6 +22911,7 @@ static virHypervisorDriver qemuHypervisorDriver = {
.domainCheckpointGetParent = qemuDomainCheckpointGetParent, /* 5.6.0 */
.domainCheckpointDelete = qemuDomainCheckpointDelete, /* 5.6.0 */
.domainGetGuestInfo = qemuDomainGetGuestInfo, /* 5.7.0 */
+ .domainAgentSetResponseTimeout = qemuDomainAgentSetResponseTimeout, /* 5.8.0 */
};
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 83477243fc..77edf0b4c4 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -8710,6 +8710,7 @@ static virHypervisorDriver hypervisor_driver = {
.domainCheckpointGetParent = remoteDomainCheckpointGetParent, /* 5.6.0 */
.domainCheckpointDelete = remoteDomainCheckpointDelete, /* 5.6.0 */
.domainGetGuestInfo = remoteDomainGetGuestInfo, /* 5.7.0 */
+ .domainAgentSetResponseTimeout = remoteDomainAgentSetResponseTimeout, /* 5.8.0 */
};
static virNetworkDriver network_driver = {
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index f4e3392212..23e42d17b1 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -3744,6 +3744,16 @@ struct remote_connect_set_identity_args {
unsigned int flags;
};
+struct remote_domain_agent_set_response_timeout_args {
+ remote_nonnull_domain dom;
+ int timeout;
+ unsigned int flags;
+};
+
+struct remote_domain_agent_set_response_timeout_ret {
+ int result;
+};
+
/*----- Protocol. -----*/
/* Define the program number, protocol version and procedure numbers here. */
@@ -6617,5 +6627,11 @@ enum remote_procedure {
* @generate: client
* @acl: connect:write
*/
- REMOTE_PROC_CONNECT_SET_IDENTITY = 419
+ REMOTE_PROC_CONNECT_SET_IDENTITY = 419,
+
+ /**
+ * @generate: both
+ * @acl: domain:write
+ */
+ REMOTE_PROC_DOMAIN_AGENT_SET_RESPONSE_TIMEOUT = 420
};
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index 51606e7473..9ad7a857e0 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -3114,6 +3114,14 @@ struct remote_connect_set_identity_args {
} params;
u_int flags;
};
+struct remote_domain_agent_set_response_timeout_args {
+ remote_nonnull_domain dom;
+ int timeout;
+ u_int flags;
+};
+struct remote_domain_agent_set_response_timeout_ret {
+ int result;
+};
enum remote_procedure {
REMOTE_PROC_CONNECT_OPEN = 1,
REMOTE_PROC_CONNECT_CLOSE = 2,
@@ -3534,4 +3542,5 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_CHECKPOINT_DELETE = 417,
REMOTE_PROC_DOMAIN_GET_GUEST_INFO = 418,
REMOTE_PROC_CONNECT_SET_IDENTITY = 419,
+ REMOTE_PROC_DOMAIN_AGENT_SET_RESPONSE_TIMEOUT = 420,
};
--
2.21.0
5 years, 1 month
[libvirt] [PATCH] docs: hacking: add missing code element
by Ján Tomko
Wrap the 'g_renew()' call for VIR_SHRINK_N in <code>.
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
Pushed as trivial.
docs/hacking.html.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/hacking.html.in b/docs/hacking.html.in
index 5d13e4f71d..06deab9e90 100644
--- a/docs/hacking.html.in
+++ b/docs/hacking.html.in
@@ -1056,7 +1056,7 @@ BAD:
<td>the newly added memory is not zeroed</td></tr>
<tr><td><code>VIR_EXPAND_N</code></td><td><code>g_renew(var_t, ptr, n)</code></td>
<td>zero the new memory manually or use an array type</td></tr>
- <tr><td><code>VIR_SHRINK_N</code></td><td>g_renew(var_t, ptr, n)</td>
+ <tr><td><code>VIR_SHRINK_N</code></td><td><code>g_renew(var_t, ptr, n)</code></td>
<td></td></tr>
<tr><td><code>VIR_APPEND_ELEMENT</code></td><td><code>g_array_append_val</code></td>
<td><code>g_ptr_array_add</code> or <code>g_byte_array_append</code></td></tr>
--
2.21.0
5 years, 1 month