[libvirt PATCH] qemu: fix response timeout for agent guest-sync
by Jonathon Jongsma
The agent 'guest-sync' command historically had a 5s response timeout
which was different from other agent commands, which waited forever.
When we added the ability to customize the response timeout for guest
agent commands, we intended to continue to use 5s for 'guest-sync' when
the user specified a response timeout greater than 5s, and use the
user-specified timeout if it was below 5s. Unfortunately, when
attempting to determine whether the user-specified timeout was less than
5s, we were comparing against an enum value of
VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT (which is -1) rather than against
the actual time value that it represented (5).
This change makes it so that 'guest-sync' now uses the user-specified
tiemout if it is less than 5s.
Signed-off-by: Jonathon Jongsma <jjongsma(a)redhat.com>
---
src/qemu/qemu_agent.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 6ff5b11374..a10ef0728a 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -904,7 +904,7 @@ qemuAgentGuestSync(qemuAgentPtr agent)
/* if user specified a custom agent timeout that is lower than the
* default timeout, use the shorter timeout instead */
- if ((agent->timeout >= 0) && (agent->timeout < timeout))
+ if ((agent->timeout >= 0) && (agent->timeout < QEMU_AGENT_WAIT_TIME))
timeout = agent->timeout;
memset(&sync_msg, 0, sizeof(sync_msg));
--
2.21.1
4 years, 9 months
[PATCH v1] qemu: Use g_autofree and g_autoptr in qemuAgentSetUserPassword
by Seeteena Thoufeek
Signed-off-by: Seeteena Thoufeek <s1seetee(a)linux.vnet.ibm.com>
---
src/qemu/qemu_agent.c | 19 ++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 9ea2c59563..1583a4eee2 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -2274,10 +2274,9 @@ qemuAgentSetUserPassword(qemuAgentPtr agent,
const char *password,
bool crypted)
{
- int ret = -1;
- virJSONValuePtr cmd = NULL;
- virJSONValuePtr reply = NULL;
- char *password64 = NULL;
+ g_autoptr(virJSONValue) cmd = NULL;
+ g_autoptr(virJSONValue) reply = NULL;
+ g_autofree char *password64 = NULL;
password64 = g_base64_encode((unsigned char *)password,
strlen(password));
@@ -2287,18 +2286,12 @@ qemuAgentSetUserPassword(qemuAgentPtr agent,
"s:username", user,
"s:password", password64,
NULL)))
- goto cleanup;
+ return -1;
if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0)
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- virJSONValueFree(cmd);
- virJSONValueFree(reply);
- VIR_FREE(password64);
- return ret;
+ return 0;
}
/* Returns: 0 on success
--
2.18.2
4 years, 9 months
[PATCH] conf: use virStringParseYesNo
by Rafael Fonseca
Use existing function built for this exact purpose.
Signed-off-by: Rafael Fonseca <r4f4rfs(a)gmail.com>
---
src/conf/domain_conf.c | 25 ++++++++++---------------
src/conf/interface_conf.c | 13 ++++++-------
2 files changed, 16 insertions(+), 22 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e0432fc47d..2fed8dff14 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9203,7 +9203,7 @@ virSecurityDeviceLabelDefParseXML(virSecurityDeviceLabelDefPtr **seclabels_rtn,
labelskip = virXMLPropString(list[i], "labelskip");
seclabels[i]->labelskip = false;
if (labelskip && !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE))
- seclabels[i]->labelskip = STREQ(labelskip, "yes");
+ ignore_value(virStringParseYesNo(labelskip, &seclabels[i]->labelskip));
VIR_FREE(labelskip);
ctxt->node = list[i];
@@ -12354,16 +12354,14 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
goto error;
if (managed_tap) {
- if (STREQ(managed_tap, "no")) {
- def->managed_tap = VIR_TRISTATE_BOOL_NO;
- } else if (STREQ(managed_tap, "yes")) {
- def->managed_tap = VIR_TRISTATE_BOOL_YES;
- } else {
+ bool state = false;
+ if (virStringParseYesNo(managed_tap, &state) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("invalid 'managed' value '%s'"),
managed_tap);
goto error;
}
+ def->managed_tap = virTristateBoolFromBool(state);
}
if (def->managed_tap != VIR_TRISTATE_BOOL_NO && ifname &&
@@ -13887,15 +13885,13 @@ virDomainTimerDefParseXML(xmlNodePtr node,
def->present = -1; /* unspecified */
if ((present = virXMLPropString(node, "present")) != NULL) {
- if (STREQ(present, "yes")) {
- def->present = 1;
- } else if (STREQ(present, "no")) {
- def->present = 0;
- } else {
+ bool state = false;
+ if (virStringParseYesNo(present, &state) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown timer present value '%s'"), present);
goto error;
}
+ def->present = state ? 1 : 0;
}
def->tickpolicy = -1;
@@ -18611,10 +18607,9 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt,
if ((node = virXPathNode("./os/bios[1]", ctxt))) {
tmp = virXMLPropString(node, "useserial");
if (tmp) {
- if (STREQ(tmp, "yes"))
- def->os.bios.useserial = VIR_TRISTATE_BOOL_YES;
- else
- def->os.bios.useserial = VIR_TRISTATE_BOOL_NO;
+ bool state = false;
+ ignore_value(virStringParseYesNo(tmp, &state));
+ def->os.bios.useserial = virTristateBoolFromBool(state);
VIR_FREE(tmp);
}
diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c
index 7a41b19ed0..d1732621b5 100644
--- a/src/conf/interface_conf.c
+++ b/src/conf/interface_conf.c
@@ -28,6 +28,7 @@
#include "virxml.h"
#include "viruuid.h"
#include "virbuffer.h"
+#include "virstring.h"
#define VIR_FROM_THIS VIR_FROM_INTERFACE
@@ -268,21 +269,19 @@ virInterfaceDefParseDhcp(virInterfaceProtocolDefPtr def,
def->dhcp = 1;
save = ctxt->node;
ctxt->node = dhcp;
+ def->peerdns = -1;
/* Not much to do in the current version */
tmp = virXPathString("string(./@peerdns)", ctxt);
if (tmp) {
- if (STREQ(tmp, "yes")) {
- def->peerdns = 1;
- } else if (STREQ(tmp, "no")) {
- def->peerdns = 0;
- } else {
+ bool state = false;
+ if (virStringParseYesNo(tmp, &state) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("unknown dhcp peerdns value %s"), tmp);
ret = -1;
+ } else {
+ def->peerdns = state ? 1 : 0;
}
VIR_FREE(tmp);
- } else {
- def->peerdns = -1;
}
ctxt->node = save;
--
2.25.1
4 years, 9 months
[PATCH] util: authconfig: use g_key_file_*
by Rafael Fonseca
Replace libvirt's virKeyFile by glib's GKeyFile.
Signed-off-by: Rafael Fonseca <r4f4rfs(a)gmail.com>
---
src/util/virauthconfig.c | 25 +++++++++++--------------
1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/src/util/virauthconfig.c b/src/util/virauthconfig.c
index fd846ddd4b..473b4c76d6 100644
--- a/src/util/virauthconfig.c
+++ b/src/util/virauthconfig.c
@@ -29,7 +29,7 @@
#include "viralloc.h"
struct _virAuthConfig {
- virKeyFilePtr keyfile;
+ GKeyFile *keyfile;
char *path;
};
@@ -46,10 +46,10 @@ virAuthConfigPtr virAuthConfigNew(const char *path)
auth->path = g_strdup(path);
- if (!(auth->keyfile = virKeyFileNew()))
+ if (!(auth->keyfile = g_key_file_new()))
goto error;
- if (virKeyFileLoadFile(auth->keyfile, path) < 0)
+ if (!g_key_file_load_from_file(auth->keyfile, path, 0, NULL))
goto error;
return auth;
@@ -71,10 +71,10 @@ virAuthConfigPtr virAuthConfigNewData(const char *path,
auth->path = g_strdup(path);
- if (!(auth->keyfile = virKeyFileNew()))
+ if (!(auth->keyfile = g_key_file_new()))
goto error;
- if (virKeyFileLoadData(auth->keyfile, path, data, len) < 0)
+ if (!g_key_file_load_from_data(auth->keyfile, data, len, 0, NULL))
goto error;
return auth;
@@ -90,7 +90,7 @@ void virAuthConfigFree(virAuthConfigPtr auth)
if (!auth)
return;
- virKeyFileFree(auth->keyfile);
+ g_key_file_free(auth->keyfile);
VIR_FREE(auth->path);
VIR_FREE(auth);
}
@@ -115,15 +115,15 @@ int virAuthConfigLookup(virAuthConfigPtr auth,
authgroup = g_strdup_printf("auth-%s-%s", service, hostname);
- if (!virKeyFileHasGroup(auth->keyfile, authgroup)) {
+ if (!g_key_file_has_group(auth->keyfile, authgroup)) {
VIR_FREE(authgroup);
authgroup = g_strdup_printf("auth-%s-%s", service, "default");
}
- if (!virKeyFileHasGroup(auth->keyfile, authgroup))
+ if (!g_key_file_has_group(auth->keyfile, authgroup))
return 0;
- if (!(authcred = virKeyFileGetValueString(auth->keyfile, authgroup, "credentials"))) {
+ if (!(authcred = g_key_file_get_string(auth->keyfile, authgroup, "credentials", NULL))) {
virReportError(VIR_ERR_CONF_SYNTAX,
_("Missing item 'credentials' in group '%s' in '%s'"),
authgroup, auth->path);
@@ -132,17 +132,14 @@ int virAuthConfigLookup(virAuthConfigPtr auth,
credgroup = g_strdup_printf("credentials-%s", authcred);
- if (!virKeyFileHasGroup(auth->keyfile, credgroup)) {
+ if (!g_key_file_has_group(auth->keyfile, credgroup)) {
virReportError(VIR_ERR_CONF_SYNTAX,
_("Missing group 'credentials-%s' referenced from group '%s' in '%s'"),
authcred, authgroup, auth->path);
return -1;
}
- if (!virKeyFileHasValue(auth->keyfile, credgroup, credname))
- return 0;
-
- *value = virKeyFileGetValueString(auth->keyfile, credgroup, credname);
+ *value = g_key_file_get_string(auth->keyfile, credgroup, credname, NULL);
return 0;
}
--
2.25.1
4 years, 9 months
[libvirt PATCH] qemu: ensure domain event thread is always stopped
by Daniel P. Berrangé
In previous commit:
commit e6afacb0feabd9bf58331aa0e5259a35378be74e
Author: Daniel P. Berrangé <berrange(a)redhat.com>
Date: Wed Feb 12 12:26:11 2020 +0000
qemu: start/stop an event loop thread for domains
A bogus comment was added claiming we didn't need to shutdown the
event thread in the qemuProcessStop method, because this would be
done in the monitor EOF callback. This was wrong because the EOF
callback only runs in the case of a QEMU crash or a guest initiated
clean shutdown & poweroff. In the case where the libvirt admin
calls virDomainDestroy, the EOF callback never fires because we
have already unregistered the event callbacks. We must thus always
attempt to stop the event thread in qemuProcessStop.
Reported-by: Peter Krempa <pkrempa(a)redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/qemu/qemu_process.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index e8401030a2..fcdde76aaa 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -7398,17 +7398,7 @@ void qemuProcessStop(virQEMUDriverPtr driver,
priv->monConfig = NULL;
}
- /*
- * We cannot stop the event thread at this time. When
- * we are in this code, we may not yet have processed the
- * STOP event or EOF from the monitor. So the event loop
- * may have pending input that we need to process still.
- * The qemuProcessHandleMonitorEOF method will kill
- * the event thread because at that point we don't
- * expect any more I/O from the QEMU monitor. We are
- * assuming we don't need to get any more events from the
- * QEMU agent at that time.
- */
+ qemuDomainObjStopWorker(vm);
/* Remove the master key */
qemuDomainMasterKeyRemove(priv);
--
2.24.1
4 years, 9 months
[PATCH v3 0/6] NVDIMM suport for pSeries guests
by Daniel Henrique Barboza
changes in v3, all proposed by Shivaprasad Bhat:
- error out when the NVDIMM is too small instead of rounding
it up to alignment
- added a new patch (#1) to update ppc64 capabilities. This new
patch can be pushed separately, but the unit tests of patch 3/6
depends on it
- previous version:
https://www.redhat.com/archives/libvir-list/2020-March/msg00406.html
Daniel Henrique Barboza (6):
qemu: capabilities: update qemu-5.0.0 capabilities for ppc64
conf: Introduce optional 'uuid' element for NVDIMM memory
formatdomain.html.in: document the new 'uuid' NVDIMM element
conf, qemu: enable NVDIMM support for ppc64
formatdomain.html.in: document NVDIMM 'label' requirement for pSeries
news.xml: document the new NVDIMM support for Pseries guests
docs/formatdomain.html.in | 24 +-
docs/news.xml | 11 +
docs/schemas/domaincommon.rng | 5 +
src/conf/domain_conf.c | 44 +-
src/conf/domain_conf.h | 3 +
src/qemu/qemu_command.c | 7 +
src/qemu/qemu_domain.c | 63 +-
src/qemu/qemu_domain.h | 4 +-
src/qemu/qemu_hotplug.c | 6 +-
tests/domaincapsdata/qemu_5.0.0.ppc64.xml | 2 +-
.../caps_5.0.0.ppc64.replies | 10949 +++++++++-------
.../qemucapabilitiesdata/caps_5.0.0.ppc64.xml | 1216 +-
...default-video-type-ppc64.ppc64-latest.args | 2 -
.../memory-hotplug-nvdimm-ppc64.args | 32 +
...ory-hotplug-nvdimm-ppc64.ppc64-latest.args | 36 +
.../memory-hotplug-nvdimm-ppc64.xml | 50 +
...ault-cpu-kvm-pseries-2.7.ppc64-latest.args | 10 +-
...ault-cpu-kvm-pseries-3.1.ppc64-latest.args | 10 +-
...ault-cpu-kvm-pseries-4.2.ppc64-latest.args | 10 +-
...ault-cpu-tcg-pseries-2.7.ppc64-latest.args | 10 +-
...ault-cpu-tcg-pseries-3.1.ppc64-latest.args | 10 +-
...ault-cpu-tcg-pseries-4.2.ppc64-latest.args | 10 +-
.../ppc64-pseries-graphics.ppc64-latest.args | 10 +-
.../ppc64-pseries-headless.ppc64-latest.args | 10 +-
.../tpm-emulator-spapr.ppc64-latest.args | 9 +-
tests/qemuxml2argvtest.c | 1 +
.../memory-hotplug-nvdimm-ppc64.xml | 50 +
tests/qemuxml2xmltest.c | 2 +
28 files changed, 7025 insertions(+), 5571 deletions(-)
create mode 100644 tests/qemuxml2argvdata/memory-hotplug-nvdimm-ppc64.args
create mode 100644 tests/qemuxml2argvdata/memory-hotplug-nvdimm-ppc64.ppc64-latest.args
create mode 100644 tests/qemuxml2argvdata/memory-hotplug-nvdimm-ppc64.xml
create mode 100644 tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-ppc64.xml
--
2.25.1
4 years, 9 months
GSOC'20: Add support for Jailhouse hypervisor to libvirt.
by PRAKHAR BANSAL
Hello All,
My name is Prakhar Bansal and I am a graduate student in Computer
Engineering at Iowa State University, US.
I have experience with Analysing Performance of Applications running inside
multiple virtual machines hosted by the libvirt QEMU-KVM through
virt-manager.
I am interested in working on the project to develop a Libvirt driver for
the Jailhouse hypervisor. I looked into the initial attempt on the
Jailhouse driver which seems to be based on the Jailhouse command-line
interface. I am currently looking into learning and understanding the
kernel APIs for jailhouse hypervisor.
I followed the below articles from Mr. Valentine Sinitsyn to begin learning
about the Jailhouse hypervisor.
https://lwn.net/Articles/578295/
https://lwn.net/Articles/578852/
Regards,
Prakhar Bansal
4 years, 9 months
Fwd: KVM hook
by Aditya Sahu
Hi Team ,
I am reaching out to you seeking your help for one of my KVM hook script.
I am using /etc/libvirt/hooks/network file to trigger an event when a
network is created or deleted ( https://www.libvirt.org/hooks.html ).
Basically I using a rest call to create the same network in my Infoblox
appliance for the network monitoring.
However every time I create a network only $2== start or $2==started gets
invoked, i have tried pretty much every combination and permutation but did
not get any success. I checked the libvirtd.log and found that only $2==
start or $2==started gets invoked.
In my case i would like to get network created in infoblox appliance as and
when it gets created in the KVM and should get deleted as and when it gets
deleted from the KVM.
Here is snippet of my script
#!/bin/bash
network_name=`xml_grep --text_only hookData/network/name
/etc/libvirt/hooks/net_details`
network=`xmllint --xpath hookData/network/ip/@address
/etc/libvirt/hooks/net_details|cut -d "=" -f2|tr -d '"'`
network_mask=`ipcalc $network |awk '/Network/{print$2}'`
if [[ $2=="begin" ]] || [[ $2=="start" ]] || [[ $2=="started" ]]; then
curl -k -u admin:infoblox -H "content-type: application/json" -X
POST "
https://10.196.200.63/wapi/v2.10/network?_return_fields%2B=network&_retur..."
-d '{"network": "'$network_mask'"}'
network_ref=`curl -k -s -u admin:infoblox -H 'content-type:
application/json' -X GET '
https://10.196.200.63/wapi/v2.10/network?_return_fields%2B=network&_retur...
'| grep $network_mask| awk -v RS=" " '/_ref/{getline;print$1}' |cut -d "/"
-f2-3`
else
curl -k -u admin:infoblox -H 'content-type: application/json' -X
DELETE "https://10.196.200.63/wapi/v2.10/network/$network_ref/default"
fi
-----------------------------------------------------------------------------------------------------------------------
This script works perfectly fine and creates the network however when i
delete the network it does not get deleted from the infoblox appliance. As
i mentioned when tailed the libvirtd.log I found that the API to create
network gets executed when the network is stopped.
Attaching libvirted.log snippet
[image: image.png]
In this screen shot, stopped hook is triggered but still network creation
API is fired which has errored out.
Any guidance or help is highly appreciated.
-Aditya
4 years, 9 months
[libvirt PATCH 0/4] src: add configurable support for cgroups usage
by Daniel P. Berrangé
This simple series allows apps to choose how cgroups are managed by
libvirt, between cgroupfs and machined, or disabled entirely.
Daniel P. Berrangé (4):
conf: allow different resource registration modes
util: allow choice between machined or direct cgroups filesystem
qemu: wire up support for controlling use of cgroups backend
lxc: wire up support for controlling use of cgroups backend
docs/formatdomain.html.in | 24 +++++++-
docs/schemas/domaincommon.rng | 17 +++++-
src/conf/domain_conf.c | 46 ++++++++++++----
src/conf/domain_conf.h | 13 +++++
src/libvirt_private.syms | 2 +
src/lxc/lxc_cgroup.c | 32 +++++++++++
src/lxc/lxc_cgroup.h | 3 +
src/lxc/lxc_process.c | 7 ++-
src/qemu/qemu_cgroup.c | 67 +++++++++++++++++++++--
src/qemu/qemu_command.c | 9 +--
src/util/vircgroup.c | 57 ++++++++++++-------
src/util/vircgroup.h | 7 +++
tests/lxcxml2xmldata/lxc-capabilities.xml | 2 +-
tests/lxcxml2xmldata/lxc-idmap.xml | 2 +-
14 files changed, 239 insertions(+), 49 deletions(-)
--
2.24.1
4 years, 9 months
[libvirt PATCH] docs: virtiofs: add missing aposthrophe
by Ján Tomko
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
Reported-by: Dr. David Alan Gilbert <dgilbert(a)redhat.com>
---
I pushed this on Monday, but forgot to send the e-mail.
docs/formatdomain.html.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index b6ddfa8e0c..594146009d 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -3981,7 +3981,7 @@
<readonly/>
</filesystem>
<filesystem type='mount' accessmode='passthrough'>
- <driver type='virtiofs queue='1024'/>
+ <driver type='virtiofs' queue='1024'/>
<binary path='/usr/libexec/virtiofsd' xattr='on'>
<cache mode='always'/>
<lock posix='on' flock='on'/>
--
2.24.1
4 years, 9 months