[libvirt] [PATCH] Unify *ReportError logic
by Cole Robinson
Currently, most src/* files have their own ReportError
function. Some support printf style arguments, others
only allow reporting a single string message. The code
for all of them does virtually the same thing, possibly
passing a different constant off to another function.
The attached patch adds a function to virterror.c which
encapsulates the common ReportError logic. I used this
to replace qemudReportError with a macro, which also
allows passing off filename and line number info if
we wanted to do something with it later.
I did just the one function conversion to see what
people think: if I'm missing something, or ideas for
anything else to add. Seems to work as expected in
my testing.
Thanks,
Cole
16 years
[libvirt] first argument in virDomainMigrate, is it free'ed?
by Stefan de Konink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
Hi,
I saw that freeing the dom after a migration takes place results in:
libvir: Domain error : invalid domain pointer in virDomainFree
Now I wonder, if this is the case, could a normale migrate function
'just' be:
domain = virDomainMigrate(domain, ....)
Or is this unsafe; for example as a domain migration fails?
Stefan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEAREKAAYFAkjqOYwACgkQYH1+F2Rqwn0NZACffFESznbeElKNVgt65YXPGzXX
ausAmwZ7HScE0/RTtDWm2uug/dC1S21K
=xpn6
-----END PGP SIGNATURE-----
16 years
[libvirt] Xen Migration does not work
by Stefan de Konink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
I'm try to migrate using libvirt:
virsh # migrate 0802367323_PIQ002 xen://xen002.local/
libvir: Xen Daemon error : POST operation failed: xend_post: error from
xen daemon: (xend.err 'Missing parameter: node')
virsh -v
0.4.6
Stefan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEAREKAAYFAkjpagoACgkQYH1+F2Rqwn0yogCfd0+rK0mNrLpmmwclAjRpevlg
w4EAn2VOWooBbch7awWpRJs/1Sn7G5ZW
=6eZd
-----END PGP SIGNATURE-----
16 years
[libvirt] [PATCH] Add generic parameter=value support for virsh's schedinfo command
by Dan Smith
This patch maintains the two Xen-specific --weight and --cap options,
but adds support for setting arbitrary parameters by specifying them in
param=value syntax.
Changes to the virsh manual are included.
Changes:
- Replace use of 'a' conversion modifier with pre-alloc
diff -r 51fd150edd42 -r e441b1a06f1c docs/virsh.pod
--- a/docs/virsh.pod Tue Oct 07 11:45:52 2008 -0700
+++ b/docs/virsh.pod Wed Oct 08 07:59:11 2008 -0700
@@ -318,12 +318,14 @@
with all the same limitations. Open network connections may be
severed upon restore, as TCP timeouts may have expired.
+=item B<schedinfo> optional I<--set> B<parameter=value> I<domain-id>
+
=item B<schedinfo> optional I<--weight> B<number> optional I<--cap> B<number> I<domain-id>
-Allows to show (and set) the domain scheduler parameters. This is currently
-only defined for XEN_CREDIT scheduler, and the optional weight and cap
-arguments allows to set the associated parameters in that scheduler if
-provided.
+Allows to show (and set) the domain scheduler parameters.
+
+B<Note>: The weight and cap parameters are defined only for the
+XEN_CREDIT scheduler and are now I<DEPRECATED>.
=item B<setmem> I<domain-id> B<kilobytes>
diff -r 51fd150edd42 -r e441b1a06f1c src/virsh.c
--- a/src/virsh.c Tue Oct 07 11:45:52 2008 -0700
+++ b/src/virsh.c Wed Oct 08 07:59:11 2008 -0700
@@ -1112,6 +1112,7 @@
static const vshCmdOptDef opts_schedinfo[] = {
{"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
+ {"set", VSH_OT_STRING, VSH_OFLAG_NONE, gettext_noop("parameter=value")},
{"weight", VSH_OT_INT, VSH_OFLAG_NONE, gettext_noop("weight for XEN_CREDIT")},
{"cap", VSH_OT_INT, VSH_OFLAG_NONE, gettext_noop("cap for XEN_CREDIT")},
{NULL, 0, 0, NULL}
@@ -1121,6 +1122,9 @@
cmdSchedinfo(vshControl *ctl, const vshCmd *cmd)
{
char *schedulertype;
+ char *set;
+ char *param_name = NULL;
+ long long int param_value = 0;
virDomainPtr dom;
virSchedParameterPtr params = NULL;
int i, ret;
@@ -1128,6 +1132,7 @@
int nr_inputparams = 0;
int inputparams = 0;
int weightfound = 0;
+ int setfound = 0;
int weight = 0;
int capfound = 0;
int cap = 0;
@@ -1141,7 +1146,7 @@
if (!(dom = vshCommandOptDomain(ctl, cmd, "domain", NULL)))
return FALSE;
- /* Currently supports Xen Credit only */
+ /* Deprecated Xen-only options */
if(vshCommandOptBool(cmd, "weight")) {
weight = vshCommandOptInt(cmd, "weight", &weightfound);
if (!weightfound) {
@@ -1160,6 +1165,25 @@
} else {
nr_inputparams++;
}
+ }
+
+ if(vshCommandOptBool(cmd, "set")) {
+ set = vshCommandOptString(cmd, "set", &setfound);
+ if (!setfound) {
+ vshError(ctl, FALSE, "%s", _("Error getting param"));
+ goto cleanup;
+ }
+
+ param_name = vshMalloc(ctl, strlen(set) + 1);
+ if (param_name == NULL)
+ goto cleanup;
+
+ if (sscanf(set, "%[^=]=%i", param_name, ¶m_value) != 2) {
+ vshError(ctl, FALSE, "%s", _("Invalid value of param"));
+ goto cleanup;
+ }
+
+ nr_inputparams++;
}
params = vshMalloc(ctl, sizeof (virSchedParameter) * nr_inputparams);
@@ -1180,7 +1204,14 @@
params[inputparams].value.ui = cap;
inputparams++;
}
- /* End Currently supports Xen Credit only */
+ /* End Deprecated Xen-only options */
+
+ if (setfound) {
+ strncpy(params[inputparams].field,param_name,sizeof(params[0].field));
+ params[inputparams].type = VIR_DOMAIN_SCHED_FIELD_LLONG;
+ params[inputparams].value.l = param_value;
+ inputparams++;
+ }
assert (inputparams == nr_inputparams);
@@ -1247,6 +1278,7 @@
}
cleanup:
free(params);
+ free(param_name);
virDomainFree(dom);
return ret_val;
}
16 years
[libvirt] [PATCH] Add generic parameter=value support for virsh's schedinfo command
by Dan Smith
This patch maintains the two Xen-specific --weight and --cap options,
but adds support for setting arbitrary parameters by specifying them in
param=value syntax.
Changes to the virsh manual are included.
diff -r 51fd150edd42 -r aae58f42bd4a docs/virsh.pod
--- a/docs/virsh.pod Tue Oct 07 11:45:52 2008 -0700
+++ b/docs/virsh.pod Tue Oct 07 13:53:49 2008 -0700
@@ -318,12 +318,14 @@
with all the same limitations. Open network connections may be
severed upon restore, as TCP timeouts may have expired.
+=item B<schedinfo> optional I<--set> B<parameter=value> I<domain-id>
+
=item B<schedinfo> optional I<--weight> B<number> optional I<--cap> B<number> I<domain-id>
-Allows to show (and set) the domain scheduler parameters. This is currently
-only defined for XEN_CREDIT scheduler, and the optional weight and cap
-arguments allows to set the associated parameters in that scheduler if
-provided.
+Allows to show (and set) the domain scheduler parameters.
+
+B<Note>: The weight and cap parameters are defined only for the
+XEN_CREDIT scheduler and are now I<DEPRECATED>.
=item B<setmem> I<domain-id> B<kilobytes>
diff -r 51fd150edd42 -r aae58f42bd4a src/virsh.c
--- a/src/virsh.c Tue Oct 07 11:45:52 2008 -0700
+++ b/src/virsh.c Tue Oct 07 13:53:49 2008 -0700
@@ -1112,6 +1112,7 @@
static const vshCmdOptDef opts_schedinfo[] = {
{"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
+ {"set", VSH_OT_STRING, VSH_OFLAG_NONE, gettext_noop("parameter=value")},
{"weight", VSH_OT_INT, VSH_OFLAG_NONE, gettext_noop("weight for XEN_CREDIT")},
{"cap", VSH_OT_INT, VSH_OFLAG_NONE, gettext_noop("cap for XEN_CREDIT")},
{NULL, 0, 0, NULL}
@@ -1121,6 +1122,9 @@
cmdSchedinfo(vshControl *ctl, const vshCmd *cmd)
{
char *schedulertype;
+ char *set;
+ char *param_name = NULL;
+ long long int param_value = 0;
virDomainPtr dom;
virSchedParameterPtr params = NULL;
int i, ret;
@@ -1128,6 +1132,7 @@
int nr_inputparams = 0;
int inputparams = 0;
int weightfound = 0;
+ int setfound = 0;
int weight = 0;
int capfound = 0;
int cap = 0;
@@ -1141,7 +1146,7 @@
if (!(dom = vshCommandOptDomain(ctl, cmd, "domain", NULL)))
return FALSE;
- /* Currently supports Xen Credit only */
+ /* Deprecated Xen-only options */
if(vshCommandOptBool(cmd, "weight")) {
weight = vshCommandOptInt(cmd, "weight", &weightfound);
if (!weightfound) {
@@ -1160,6 +1165,21 @@
} else {
nr_inputparams++;
}
+ }
+
+ if(vshCommandOptBool(cmd, "set")) {
+ set = vshCommandOptString(cmd, "set", &setfound);
+ if (!setfound) {
+ vshError(ctl, FALSE, "%s", _("Error getting param"));
+ goto cleanup;
+ }
+
+ if (sscanf(set, "%a[^=]=%i", ¶m_name, ¶m_value) != 2) {
+ vshError(ctl, FALSE, "%s", _("Invalid value of param"));
+ goto cleanup;
+ }
+
+ nr_inputparams++;
}
params = vshMalloc(ctl, sizeof (virSchedParameter) * nr_inputparams);
@@ -1180,7 +1200,14 @@
params[inputparams].value.ui = cap;
inputparams++;
}
- /* End Currently supports Xen Credit only */
+ /* End Deprecated Xen-only options */
+
+ if (setfound) {
+ strncpy(params[inputparams].field,param_name,sizeof(params[0].field));
+ params[inputparams].type = VIR_DOMAIN_SCHED_FIELD_LLONG;
+ params[inputparams].value.l = param_value;
+ inputparams++;
+ }
assert (inputparams == nr_inputparams);
@@ -1247,6 +1274,7 @@
}
cleanup:
free(params);
+ free(param_name);
virDomainFree(dom);
return ret_val;
}
16 years
[libvirt] [PATCH] Fix qemudDomainShutdown() memory leak
by Eduardo Habkost
qemudDomainShutdown() currently doesn't free the returned reply from
qemudMonitorCommand().
Signed-off-by: Eduardo Habkost <ehabkost(a)redhat.com>
---
src/qemu_driver.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 806608d..a88cb75 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -2176,6 +2176,7 @@ static int qemudDomainShutdown(virDomainPtr dom) {
"%s", _("shutdown operation failed"));
return -1;
}
+ VIR_FREE(info);
return 0;
}
--
1.5.5.GIT
16 years
[libvirt] 141 format string warnings
by Jim Meyering
Hello,
I count 141 warnings like this:
util.c:177: warning: format not a string literal and no format arguments
If anyone is in the process of fixing those, please let me know soon.
16 years
[libvirt] [PATCH] (virCgroupSetValueStr): Use safe_write, not write.
by Jim Meyering
"make syntax-check" was failing.
This fixes it:
>From 155aea5141553fd9fab19aedc4df1613abae771c Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Tue, 7 Oct 2008 23:10:03 +0200
Subject: [PATCH] Tue Oct 7 23:08:51 CEST 2008 Jim Meyering <meyering(a)redhat.com>
* src/cgroup.c (virCgroupSetValueStr): Use safe_write, not write.
---
ChangeLog | 4 ++++
src/cgroup.c | 2 +-
2 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 619d2b6..88b746e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Tue Oct 7 23:08:51 CEST 2008 Jim Meyering <meyering(a)redhat.com>
+
+ * src/cgroup.c (virCgroupSetValueStr): Use safe_write, not write.
+
Tue Oct 7 18:33:39 CEST 2008 Daniel Veillard <veillard(a)redhat.com>
* src/qemu_driver.c: another OOM handling cleanup (Guido Günther)
diff --git a/src/cgroup.c b/src/cgroup.c
index a7d2ca9..ed206dc 100644
--- a/src/cgroup.c
+++ b/src/cgroup.c
@@ -649,7 +649,7 @@ int virCgroupAddTask(virCgroupPtr group, pid_t pid)
goto done;
}
- if (write(fd, pidstr, strlen(pidstr)) <= 0) {
+ if (safe_write(fd, pidstr, strlen(pidstr)) <= 0) {
rc = -errno;
goto done;
}
--
1.6.0.2.307.gc4275
16 years
[libvirt] virsh connect
by devi thapa
Hi All,
I have created a virtual network using virsh.
I want to connect to the virtual machine, without being asked password.
Can I achieve this using command
virsh connect <name>
Please help me out with this.
Regards,
Devi.
16 years
[libvirt] [PATCH] Reboot support for QEMU/KVM
by Eduardo Habkost
This patch implements reboot support on qemu_driver.
It is so simple that I am wondering if there is some problem I am missing,
that would be the reason it wasn't implemented yet. I hope not. :)
Signed-off-by: Eduardo Habkost <ehabkost(a)redhat.com>
---
src/qemu_driver.c | 23 ++++++++++++++++++++++-
1 files changed, 22 insertions(+), 1 deletions(-)
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index a88cb75..9ce53ad 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -2182,6 +2182,27 @@ static int qemudDomainShutdown(virDomainPtr dom) {
}
+static int qemudDomainReboot(virDomainPtr dom) {
+ struct qemud_driver *driver = (struct qemud_driver *)dom->conn->privateData;
+ virDomainObjPtr vm = virDomainFindByID(driver->domains, dom->id);
+ char* info;
+
+ if (!vm) {
+ qemudReportError(dom->conn, dom, NULL, VIR_ERR_INVALID_DOMAIN,
+ _("no domain with matching id %d"), dom->id);
+ return -1;
+ }
+
+ if (qemudMonitorCommand(driver, vm, "system_reset", &info) < 0) {
+ qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
+ "%s", _("reboot operation failed"));
+ return -1;
+ }
+ VIR_FREE(info);
+ return 0;
+}
+
+
static int qemudDomainDestroy(virDomainPtr dom) {
struct qemud_driver *driver = (struct qemud_driver *)dom->conn->privateData;
virDomainObjPtr vm = virDomainFindByID(driver->domains, dom->id);
@@ -4032,7 +4053,7 @@ static virDriver qemuDriver = {
qemudDomainSuspend, /* domainSuspend */
qemudDomainResume, /* domainResume */
qemudDomainShutdown, /* domainShutdown */
- NULL, /* domainReboot */
+ qemudDomainReboot, /* domainReboot */
qemudDomainDestroy, /* domainDestroy */
qemudDomainGetOSType, /* domainGetOSType */
qemudDomainGetMaxMemory, /* domainGetMaxMemory */
--
1.5.5.GIT
16 years