[libvirt] RPC ref count question
by Radu Caragea
Hi everyone,
>From what I understand after defining a domain with
remoteDomainCreateXML, the corresponding destroy call is
remoteDomainDestroy, both from the automatically generated
remote_client_bodies.h
My question is why the domain isn't freed in the destroy procedure
(with virUnrefDomain or other) ? Is it supposed to be called
separately or is it a bug ? I'm asking because from what I saw the
connection refcount increments in domain creation but doesn't
decrement in destroy.
12 years, 6 months
[libvirt] can not connect hypervisor using libvirt-0.9.11 on windows
by xuteng
Hi,ALL:
I compiled the libvirt-0.9.11 source code with mingw on windows according to the website:
https://github.com/photron/msys_setup
Then I wrote a simple test case ,as below:
#include <stdio.h>
#include <stdlib.h>
#include "libvirt/libvirt.h"
int main(int argc,char **argv)
{
virConnectPtr conn;
conn = virConnectOpen("qemu+tcp://192.168.1.6/system");
if (conn = NULL)
{
fprintf(stderr,"Failed to open connection to qemu+tcp://192.168.1.6/system");
return 1;
}
virConnectClose(conn);
return 0;
}
When linked to the dll just compiled , it came out with error :
NOTE: you should run 'diskperf -y' to enable the disk statistics
libvir: RPC error : Unable to set close-on-exec flag: No such file or directory
libvir: error : invalid connection pointer in virConnectClose
When using gdb to debug the testcase , break the function virConnectOpen , then step ,the error info was:
Program received signal ?,Unknown signal.
0x7c92e4ff in ntdll!LdrAlternateResourcesEnabled ()
from C:\WINDOWS.0\system32\ntdll.dll
Any suggestion would be appreciated !
Best Regards!
xuteng via foxmail
12 years, 6 months
[libvirt] [PATCH] virsh: Null terminated the string memcpy from buffer explicitly
by Osier Yang
---
tools/virsh.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 98305c0..4509020 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -15069,11 +15069,13 @@ cleanup:
VIR_FREE(device_type);
VIR_FREE(disk_type);
if (xml_buf) {
- if (VIR_ALLOC_N(ret, xmlBufferLength(xml_buf)) < 0) {
+ int len = xmlBufferLength(xml_buf);
+ if (VIR_ALLOC_N(ret, len + 1) < 0) {
virReportOOMError();
return NULL;
}
- memcpy(ret, (char *)xmlBufferContent(xml_buf), xmlBufferLength(xml_buf));
+ memcpy(ret, (char *)xmlBufferContent(xml_buf), len);
+ ret[len] = '\0';
xmlBufferFree(xml_buf);
}
return ret;
--
1.7.7.3
12 years, 6 months
[libvirt] [PATCH] Always pivot_root event if the new root source is '/'
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
This reverts
commit c16b4c43fcdd8ec02581f38377983b2e0925bfcd
Author: Daniel P. Berrange <berrange(a)redhat.com>
Date: Fri May 11 15:09:27 2012 +0100
Avoid LXC pivot root in the root source is still /
This commit broke setup of /dev, because the code which
deals with setting up a private /dev and /dev/pts only
works if you do a pivotroot.
The original intent of avoiding the pivot root was to
try and ensure the new root has a minimumal mount
tree. The better way todo this is to just unmount the
bits we don't want (ie old /proc & /sys subtrees.
So apply the logic from
commit c529b47a756960d332fbe9903943dae855e7b949
Author: Daniel P. Berrange <berrange(a)redhat.com>
Date: Fri May 11 11:35:28 2012 +0100
Trim /proc & /sys subtrees before mounting new instances
to the pivot_root codepath as well
---
src/lxc/lxc_container.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index bad7938..b8fb14e 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -1345,6 +1345,13 @@ static int lxcContainerSetupPivotRoot(virDomainDefPtr vmDef,
if (lxcContainerPivotRoot(root) < 0)
goto cleanup;
+ /* Gets rid of any existing stuff under /proc, since we need new
+ * namespace aware versions of those. We must do /proc second
+ * otherwise we won't find /proc/mounts :-) */
+ if (lxcContainerUnmountSubtree("/sys", false) < 0 ||
+ lxcContainerUnmountSubtree("/proc", false) < 0)
+ goto cleanup;
+
/* Mounts the core /proc, /sys, etc filesystems */
if (lxcContainerMountBasicFS(vmDef, true, securityDriver) < 0)
goto cleanup;
@@ -1472,11 +1479,7 @@ static int lxcContainerSetupMounts(virDomainDefPtr vmDef,
if (lxcContainerResolveSymlinks(vmDef) < 0)
return -1;
- /* If the user has specified a dst '/' with a source of '/'
- * then we don't really want to go down the pivot root
- * path, as we're just tuning the existing root
- */
- if (root && root->src && STRNEQ(root->src, "/"))
+ if (root && root->src)
return lxcContainerSetupPivotRoot(vmDef, root, ttyPaths, nttyPaths, securityDriver);
else
return lxcContainerSetupExtraMounts(vmDef, root, securityDriver);
--
1.7.10.2
12 years, 6 months
[libvirt] [PATCH] Improve error message diagnosing incorrect XML CPU mode
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Tell the user what CPU mode value is wrong
---
src/conf/cpu_conf.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index 018d571..b520f7c 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -234,13 +234,15 @@ virCPUDefParseXML(const xmlNodePtr node,
goto error;
} else {
def->mode = virCPUModeTypeFromString(cpuMode);
- VIR_FREE(cpuMode);
if (def->mode < 0) {
- virCPUReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Invalid mode attribute"));
+ virCPUReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Invalid mode attribute '%s'"),
+ cpuMode);
+ VIR_FREE(cpuMode);
goto error;
}
+ VIR_FREE(cpuMode);
}
} else {
if (def->type == VIR_CPU_TYPE_HOST)
--
1.7.10.2
12 years, 6 months
Re: [libvirt] [Qemu-devel] [PATCH v2 2/4] qapi: Add passfd QMP command
by Luiz Capitulino
On Fri, 8 Jun 2012 11:42:57 -0400
Corey Bryant <coreyb(a)linux.vnet.ibm.com> wrote:
> This patch adds the passfd QMP command using the QAPI framework.
> Like the getfd command, it is used to pass a file descriptor via
> SCM_RIGHTS. However, the passfd command also returns the received
> file descriptor, which is a difference in behavior from the getfd
> command, which returns nothing.
Let's call it pass-fd instead.
Also, getfd automatically closes a fd if an existing fdname is passed again.
I don't think this is a good behavior, I think pass-fd should fail instead
(note that we can't fix getfd though).
>
> The closefd command can be used to close a file descriptor that was
> passed with the passfd command.
>
> v2:
> -Introduce new QMP command to pass/return fd (lcapitulino(a)redhat.com)
> -Use passfd as command name (berrange(a)redhat.com)
>
> Signed-off-by: Corey Bryant <coreyb(a)linux.vnet.ibm.com>
> ---
> monitor.c | 14 ++++++++++----
> qapi-schema.json | 15 +++++++++++++++
> qmp-commands.hx | 27 +++++++++++++++++++++++++++
> 3 files changed, 52 insertions(+), 4 deletions(-)
>
> diff --git a/monitor.c b/monitor.c
> index 4c53cb6..980a226 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -2182,7 +2182,7 @@ static void do_inject_mce(Monitor *mon, const QDict *qdict)
> }
> #endif
>
> -void qmp_getfd(const char *fdname, Error **errp)
> +int64_t qmp_passfd(const char *fdname, Error **errp)
> {
> mon_fd_t *monfd;
> int fd;
> @@ -2190,13 +2190,13 @@ void qmp_getfd(const char *fdname, Error **errp)
> fd = qemu_chr_fe_get_msgfd(cur_mon->chr);
> if (fd == -1) {
> error_set(errp, QERR_FD_NOT_SUPPLIED);
> - return;
> + return -1;
> }
>
> if (qemu_isdigit(fdname[0])) {
> error_set(errp, QERR_INVALID_PARAMETER_VALUE, "fdname",
> "a name not starting with a digit");
> - return;
> + return -1;
> }
>
> QLIST_FOREACH(monfd, &cur_mon->fds, next) {
> @@ -2206,7 +2206,7 @@ void qmp_getfd(const char *fdname, Error **errp)
>
> close(monfd->fd);
> monfd->fd = fd;
> - return;
> + return fd;
> }
>
> monfd = g_malloc0(sizeof(mon_fd_t));
> @@ -2214,6 +2214,12 @@ void qmp_getfd(const char *fdname, Error **errp)
> monfd->fd = fd;
>
> QLIST_INSERT_HEAD(&cur_mon->fds, monfd, next);
> + return fd;
> +}
> +
> +void qmp_getfd(const char *fdname, Error **errp)
> +{
> + qmp_passfd(fdname, errp);
> return;
> }
>
> diff --git a/qapi-schema.json b/qapi-schema.json
> index 6be1d90..15da1b8 100644
> --- a/qapi-schema.json
> +++ b/qapi-schema.json
> @@ -1864,6 +1864,21 @@
> { 'command': 'netdev_del', 'data': {'id': 'str'} }
>
> ##
> +# @passfd:
> +#
> +# Pass a file descriptor via SCM rights and assign it a name
> +#
> +# @fdname: file descriptor name
> +#
> +# Returns: The QEMU file descriptor that was received
> +# If file descriptor was not received, FdNotSupplied
> +# If @fdname is not valid, InvalidParameterType
> +#
> +# Since: 1.2.0
> +##
> +{ 'command': 'passfd', 'data': {'fdname': 'str'}, 'returns': 'int' }
> +
> +##
> # @getfd:
> #
> # Receive a file descriptor via SCM rights and assign it a name
> diff --git a/qmp-commands.hx b/qmp-commands.hx
> index f8c0f68..338a0b3 100644
> --- a/qmp-commands.hx
> +++ b/qmp-commands.hx
> @@ -869,6 +869,33 @@ Example:
> EQMP
>
> {
> + .name = "passfd",
> + .args_type = "fdname:s",
> + .params = "passfd name",
> + .help = "pass a file descriptor via SCM rights and assign it a name",
> + .mhandler.cmd_new = qmp_marshal_input_passfd,
> + },
> +
> +SQMP
> +passfd
> +------
> +
> +Pass a file descriptor via SCM rights and assign it a name.
> +
> +Arguments:
> +
> +- "fdname": file descriptor name (json-string)
> +
> +Return a json-int with the QEMU file descriptor that was received.
> +
> +Example:
> +
> +-> { "execute": "passfd", "arguments": { "fdname": "fd1" } }
> +<- { "return": 42 }
> +
> +EQMP
> +
> + {
> .name = "getfd",
> .args_type = "fdname:s",
> .params = "getfd name",
12 years, 6 months
[libvirt] [PATCH] qemu: Enable disconnecting SPICE clients without changing password
by Peter Krempa
Libvirt updates the configuration of SPICE server only when something
changes. This is unfortunate when the user wants to disconnect a
existing spice session when the connected attribute is already
"disconnect".
This patch modifies the conditions for calling the password updater to
be called when nothing changes, but the connected attribute is already
"disconnect".
---
src/qemu/qemu_hotplug.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 51b8915..c2fa75b 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1539,7 +1539,7 @@ qemuDomainChangeGraphics(struct qemud_driver *driver,
_("cannot change listen address setting on spice graphics"));
return -1;
}
- if (STRNEQ_NULLABLE(oldListenNetwork,newListenNetwork)) {
+ if (STRNEQ_NULLABLE(oldListenNetwork, newListenNetwork)) {
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot change listen network setting on spice graphics"));
return -1;
@@ -1551,11 +1551,16 @@ qemuDomainChangeGraphics(struct qemud_driver *driver,
return -1;
}
- /* If a password lifetime was, or is set, then we must always run,
- * even if new password matches old password */
+ /* We must reset the password if it has changed but also if:
+ * - password lifetime is or was set
+ * - the requested action has changed
+ * - the action is "disconnect"
+ */
if (olddev->data.spice.auth.expires ||
dev->data.spice.auth.expires ||
olddev->data.spice.auth.connected != dev->data.spice.auth.connected ||
+ dev->data.spice.auth.connected ==
+ VIR_DOMAIN_GRAPHICS_AUTH_CONNECTED_DISCONNECT ||
STRNEQ_NULLABLE(olddev->data.spice.auth.passwd,
dev->data.spice.auth.passwd)) {
VIR_DEBUG("Updating password on SPICE server %p %p",
--
1.7.8.6
12 years, 6 months
[libvirt] [PATCH v3] virsh: Honor reedit opts printing to a function
by Michal Privoznik
When printing reedit options we make stdin raw. However,
this results in stdout being raw as well. Therefore we need
to return carriage when doing new line. Unfortunately,
'\r' cannot be part of internationalized messages hence
we must move them to formatting string which then in turn
become huge and disarranged. To solve this, a new function
is introduced which takes variable string arguments and
prepend each with "\r\n" just before printing.
---
tools/virsh.c | 24 ++++++++++++++++++++----
1 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 98305c0..938f8c8 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -655,6 +655,19 @@ vshReconnect(vshControl *ctl)
ctl->useSnapshotOld = false;
}
+static void
+vshPrintRaw(vshControl *ctl, ...)
+{
+ va_list ap;
+ char *key;
+
+ va_start(ap, ctl);
+ while ((key = va_arg(ap, char *)) != NULL) {
+ vshPrint(ctl, "%s\r\n", key);
+ }
+ va_end(ap);
+}
+
/**
* vshAskReedit:
* @msg: Question to ask user
@@ -690,10 +703,13 @@ vshAskReedit(vshControl *ctl, const char *msg)
c = c_tolower(getchar());
if (c == '?') {
- vshPrint(ctl, "\r\n%s", _("y - yes, start editor again\n"
- "n - no, throw away my changes\n"
- "f - force, try to redefine again\n"
- "? - print this help\n"));
+ vshPrintRaw(ctl,
+ "",
+ _("y - yes, start editor again"),
+ _("n - no, throw away my changes"),
+ _("f - force, try to redefine again"),
+ _("? - print this help"),
+ NULL);
continue;
} else if (c == 'y' || c == 'n' || c == 'f') {
break;
--
1.7.8.5
12 years, 6 months
[libvirt] [PATCH] virsh: Report name from edited object
by Michal Privoznik
There is a little easter egg in virsh: one can easily clone
an object (domain, network, ...). Just 'virsh edit' change the name
and remove <uuid>. And then, in the end when reporting success
the new name was printed out.
However, with recent edit rewrite we lost the final part and are
still printing the original name out.
---
Or even better - if name changes, we can choose better message,
something like "New domain %s defined". But I am not sure
we want to expose this easter egg to users.
tools/virsh.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 938f8c8..0b42f1a 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -8612,7 +8612,7 @@ cmdInterfaceEdit(vshControl *ctl, const vshCmd *cmd)
#include "virsh-edit.c"
vshPrint(ctl, _("Interface %s XML configuration edited.\n"),
- virInterfaceGetName(iface));
+ virInterfaceGetName(iface_edited));
ret = true;
@@ -10006,7 +10006,7 @@ cmdNWFilterEdit(vshControl *ctl, const vshCmd *cmd)
#include "virsh-edit.c"
vshPrint(ctl, _("Network filter %s XML configuration edited.\n"),
- virNWFilterGetName(nwfilter));
+ virNWFilterGetName(nwfilter_edited));
ret = true;
@@ -15811,7 +15811,7 @@ cmdEdit(vshControl *ctl, const vshCmd *cmd)
#include "virsh-edit.c"
vshPrint(ctl, _("Domain %s XML configuration edited.\n"),
- virDomainGetName(dom));
+ virDomainGetName(dom_edited));
ret = true;
@@ -15883,7 +15883,7 @@ cmdNetworkEdit(vshControl *ctl, const vshCmd *cmd)
#include "virsh-edit.c"
vshPrint(ctl, _("Network %s XML configuration edited.\n"),
- virNetworkGetName(network));
+ virNetworkGetName(network_edited));
ret = true;
@@ -15938,7 +15938,7 @@ cmdPoolEdit(vshControl *ctl, const vshCmd *cmd)
#include "virsh-edit.c"
vshPrint(ctl, _("Pool %s XML configuration edited.\n"),
- virStoragePoolGetName(pool));
+ virStoragePoolGetName(pool_edited));
ret = true;
--
1.7.8.5
12 years, 6 months
[libvirt] [PATCH 0/2] fix two issues while doing virsh attach-disk
by Peter Krempa
First issue was caused by virsh generating invalid XML to attach the disk,
and the second issue is a off-by-one error that crashes the daemon with 50-90%
probability while doing virsh attach-disk dom /dev/zero vdx.
Peter Krempa (2):
virsh: Don't generate invalid XML in attach-disk command
qemu: Fix off-by-one error while unescaping monitor strings
src/qemu/qemu_monitor.c | 11 +++--------
tools/virsh.c | 16 ++++++++--------
2 files changed, 11 insertions(+), 16 deletions(-)
--
1.7.8.6
12 years, 6 months