[libvirt] [PATCH 0/3] Enable automatic kill of running guests
by Daniel P. Berrange
I am building an application which uses KVM to run specific tasks, rather
than as a general purpose guest OS. I want to ensure that when the app
exits, the guest goes away too. To enable this, this series introduces
the concept of 'autokill', whereby a guest is forcably destroyed when
the virConnectPtr that launched it closes. This also lets us fix a long
standing problem with migration leaving an unkillable guest
13 years, 3 months
[libvirt] [PATCH] maint: fix spelling errors on lose
by Eric Blake
* docs/drvqemu.html.in: Fix typo.
* src/libvirt.c (virDomainCreateXML, virDomainCreateWithFlags):
Likewise.
---
Pushing under the trivial rule.
I lose my sanity when people are too loose with their spelling,
resulting in this common typo :)
docs/drvqemu.html.in | 2 +-
src/libvirt.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/docs/drvqemu.html.in b/docs/drvqemu.html.in
index 038ecc6..4da3817 100644
--- a/docs/drvqemu.html.in
+++ b/docs/drvqemu.html.in
@@ -208,7 +208,7 @@ chmod o+x /path/to/directory
<p>
If the QEMU driver is configured to run virtual machines as non-root,
- then they will already loose all their process capabilities at time
+ then they will already lose all their process capabilities at time
of startup. The Linux capability feature is thus aimed primarily at
the scenario where the QEMU processes are running as root. In this
case, before launching a QEMU virtual machine, libvirtd will use
diff --git a/src/libvirt.c b/src/libvirt.c
index b8fe1b1..65a099b 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -1820,7 +1820,7 @@ virDomainGetConnect (virDomainPtr dom)
* If the VIR_DOMAIN_START_AUTODESTROY flag is set, the guest
* domain will be automatically destroyed when the virConnectPtr
* object is finally released. This will also happen if the
- * client application crashes / looses its connection to the
+ * client application crashes / loses its connection to the
* libvirtd daemon. Any domains marked for auto destroy will
* block attempts at migration or save-to-file
*
@@ -7071,7 +7071,7 @@ error:
* If the VIR_DOMAIN_START_AUTODESTROY flag is set, the guest
* domain will be automatically destroyed when the virConnectPtr
* object is finally released. This will also happen if the
- * client application crashes / looses its connection to the
+ * client application crashes / loses its connection to the
* libvirtd daemon. Any domains marked for auto destroy will
* block attempts at migration or save-to-file
*
--
1.7.4.4
13 years, 3 months
[libvirt] [PATCH] Fix generator to cope with call-by-ref long types
by Jim Fehlig
From: Matthias Bolte <matthias.bolte(a)googlemail.com>
Tested-by: Jim Fehlig <jfehlig(a)novell.com>
Matthias provided this patch to fix an issue I encountered in the
generator with APIs containing call-by-ref long type, e.g.
int virDomainMigrateGetMaxSpeed(virDomainPtr domain,
unsigned long *bandwidth,
unsigned int flags);
---
src/rpc/gendispatch.pl | 29 +++++++++++++++++++++++++++--
1 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl
index 0d344e8..f671ff0 100755
--- a/src/rpc/gendispatch.pl
+++ b/src/rpc/gendispatch.pl
@@ -640,10 +640,11 @@ elsif ($opt_b) {
} elsif ($ret_member =~ m/^(?:unsigned )?hyper (\S+)<\S+>;/) {
# error out on unannotated arrays
die "hyper array without insert@<offset> annotation: $ret_member";
- } elsif ($ret_member =~ m/^(unsigned )?hyper (\S+);/) {
+ } elsif ($ret_member =~ m/^(unsigned )?hyper (\S+);(?:\s*\/\*\s*insert@(\d+)\s*\*\/)?/) {
my $type_name = $1;
my $ret_name = $2;
my $ret_assign;
+ my $insert = $3;
if (hyper_to_long($call->{ProcName}, "ret", $ret_name)) {
my $sign = ""; $sign = "U" if ($1);
@@ -657,7 +658,13 @@ elsif ($opt_b) {
push(@vars_list, "$type_name $ret_name");
push(@ret_list, $ret_assign);
- $single_ret_var = $ret_name;
+
+ if ($insert) {
+ splice(@args_list, int($insert), 0, "&$ret_name");
+ $single_ret_var = undef;
+ } else {
+ $single_ret_var = $ret_name;
+ }
if ($call->{ProcName} eq "DomainGetMaxMemory" or
$call->{ProcName} eq "NodeGetFreeMemory") {
@@ -1285,6 +1292,24 @@ elsif ($opt_k) {
$single_ret_var = "int rv = -1";
$single_ret_type = "int";
+ } elsif ($ret_member =~ m/^(unsigned )?hyper (\S+);\s*\/\*\s*insert@(\d+)\s*\*\//) {
+ my $type_name = $1;
+ my $sign = ""; $sign = "U" if ($1);
+ my $ret_name = $2;
+ my $insert = $3;
+
+ if (hyper_to_long($call->{ProcName}, "ret", $ret_name)) {
+ $type_name .= "long";
+ push(@ret_list, "if ($ret_name) HYPER_TO_${sign}LONG(*$ret_name, ret.$ret_name);");
+ } else {
+ $type_name .= "long long";
+ push(@ret_list, "if ($ret_name) *$ret_name = ret.$ret_name;");
+ }
+
+ splice(@args_list, int($insert), 0, ("$type_name *$ret_name"));
+ push(@ret_list, "rv = 0;");
+ $single_ret_var = "int rv = -1";
+ $single_ret_type = "int";
} elsif ($ret_member =~ m/^unsigned hyper (\S+);/) {
my $ret_name = $1;
--
1.7.5.4
13 years, 3 months
[libvirt] [PATCH] schedinfo: update man page about virsh schedinfo command
by Taku Izumi
This patch updates the man page about virsh schedinfo command.
- fix typo: 1844674407370955 -> 18446744073709551
- describe the value 0 of vcpu_period and vcpu_quota parameters
Signd-off-by: Taku Izumi <izumi.taku(a)jp.fujitsu.com>
---
tools/virsh.pod | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
Index: libvirt/tools/virsh.pod
===================================================================
--- libvirt.orig/tools/virsh.pod
+++ libvirt/tools/virsh.pod
@@ -736,8 +736,9 @@ B<Note>: The weight and cap parameters a
XEN_CREDIT scheduler and are now I<DEPRECATED>.
B<Note>: The vcpu_period parameter has a valid value range of 1000-1000000 or
-0, and the vcpu_quota parameter has a valid value range of 1000-1844674407370955
-or less than 0.
+0, and the vcpu_quota parameter has a valid value range of 1000-18446744073709551
+or less than 0. The value 0 for each parameters means no value, so it is
+meaningless to specify 0 (Nothing happens).
=item B<screenshot> I<domain-id> [I<imagefilepath>] [I<--screen> B<screenID>]
13 years, 3 months
[libvirt] [PATCH] rpc: Don't close connection if program is unknown
by Jiri Denemark
In case we add a new program in the future (we did that in the past and
we are going to do it again soon) current daemon will behave badly with
new client that wants to use the new program. Before the RPC rewrite we
used to just sent an error reply to any request with unknown program.
With the RPC rewrite in 0.9.3 the daemon just closes the connection
through which such request was sent. This patch fixes this regression.
---
src/rpc/virnetserver.c | 18 +++++++++---------
src/rpc/virnetserverprogram.c | 36 ++++++++++++++++++++++++++++++------
src/rpc/virnetserverprogram.h | 4 ++++
3 files changed, 43 insertions(+), 15 deletions(-)
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index 1a49dbb..fd8781d 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -143,10 +143,12 @@ static void virNetServerHandleJob(void *jobOpaque, void *opaque)
}
if (!prog) {
- VIR_DEBUG("Cannot find program %d version %d",
- job->msg->header.prog,
- job->msg->header.vers);
- goto error;
+ if (virNetServerProgramUnknownError(job->client,
+ job->msg,
+ &job->msg->header) < 0)
+ goto error;
+ else
+ goto cleanup;
}
virNetServerProgramRef(prog);
@@ -159,20 +161,18 @@ static void virNetServerHandleJob(void *jobOpaque, void *opaque)
goto error;
virNetServerLock(srv);
+
+cleanup:
virNetServerProgramFree(prog);
virNetServerUnlock(srv);
virNetServerClientFree(job->client);
-
VIR_FREE(job);
return;
error:
- virNetServerUnlock(srv);
- virNetServerProgramFree(prog);
virNetMessageFree(job->msg);
virNetServerClientClose(job->client);
- virNetServerClientFree(job->client);
- VIR_FREE(job);
+ goto cleanup;
}
diff --git a/src/rpc/virnetserverprogram.c b/src/rpc/virnetserverprogram.c
index ca80ae0..ac3f0fd 100644
--- a/src/rpc/virnetserverprogram.c
+++ b/src/rpc/virnetserverprogram.c
@@ -110,7 +110,8 @@ static virNetServerProgramProcPtr virNetServerProgramGetProc(virNetServerProgram
static int
-virNetServerProgramSendError(virNetServerProgramPtr prog,
+virNetServerProgramSendError(unsigned program,
+ unsigned version,
virNetServerClientPtr client,
virNetMessagePtr msg,
virNetMessageErrorPtr rerr,
@@ -119,13 +120,13 @@ virNetServerProgramSendError(virNetServerProgramPtr prog,
int serial)
{
VIR_DEBUG("prog=%d ver=%d proc=%d type=%d serial=%d msg=%p rerr=%p",
- prog->program, prog->version, procedure, type, serial, msg, rerr);
+ program, version, procedure, type, serial, msg, rerr);
virNetMessageSaveError(rerr);
/* Return header. */
- msg->header.prog = prog->program;
- msg->header.vers = prog->version;
+ msg->header.prog = program;
+ msg->header.vers = version;
msg->header.proc = procedure;
msg->header.type = type;
msg->header.serial = serial;
@@ -170,7 +171,8 @@ virNetServerProgramSendReplyError(virNetServerProgramPtr prog,
* For data streams, errors are sent back as data streams
* For method calls, errors are sent back as method replies
*/
- return virNetServerProgramSendError(prog,
+ return virNetServerProgramSendError(prog->program,
+ prog->version,
client,
msg,
rerr,
@@ -187,7 +189,8 @@ int virNetServerProgramSendStreamError(virNetServerProgramPtr prog,
int procedure,
int serial)
{
- return virNetServerProgramSendError(prog,
+ return virNetServerProgramSendError(prog->program,
+ prog->version,
client,
msg,
rerr,
@@ -197,6 +200,27 @@ int virNetServerProgramSendStreamError(virNetServerProgramPtr prog,
}
+int virNetServerProgramUnknownError(virNetServerClientPtr client,
+ virNetMessagePtr msg,
+ virNetMessageHeaderPtr req)
+{
+ virNetMessageError rerr;
+
+ virNetError(VIR_ERR_RPC,
+ _("Cannot find program %d version %d"), req->prog, req->vers);
+
+ memset(&rerr, 0, sizeof(rerr));
+ return virNetServerProgramSendError(req->prog,
+ req->vers,
+ client,
+ msg,
+ &rerr,
+ req->proc,
+ VIR_NET_REPLY,
+ req->serial);
+}
+
+
static int
virNetServerProgramDispatchCall(virNetServerProgramPtr prog,
virNetServerPtr server,
diff --git a/src/rpc/virnetserverprogram.h b/src/rpc/virnetserverprogram.h
index ca31b7e..06b16d7 100644
--- a/src/rpc/virnetserverprogram.h
+++ b/src/rpc/virnetserverprogram.h
@@ -86,6 +86,10 @@ int virNetServerProgramSendStreamError(virNetServerProgramPtr prog,
int procedure,
int serial);
+int virNetServerProgramUnknownError(virNetServerClientPtr client,
+ virNetMessagePtr msg,
+ virNetMessageHeaderPtr req);
+
int virNetServerProgramSendStreamData(virNetServerProgramPtr prog,
virNetServerClientPtr client,
virNetMessagePtr msg,
--
1.7.6.1
13 years, 3 months
[libvirt] [PATCH 0/3 TCK] Some tests for snapshot management
by Daniel P. Berrange
All these tests fail with current GIT, but are intended to work
with Eric's snapshot series applied.
The first test in this list, however, does not pass.
Eric's current tree forbids calling 'Destroy' on a transient
guest which has snapshots present. IMHO this is wrong, because
the guest may itself exit at any time, which leaves us in the
same state as is 'Destroy' had been called wrt snapshots.
IMHO, we should be allowed to call 'virDomainDestroy' on a
transient guest with snapshots, and then later 'virDomainCreateXML'
to re-create the guest and still have access to the snapshots
In other words, just because a transient guest is not currently
present, does not mean we should forget about its snapshots as
a management app can re-create it again at any time.
Forbidding virDomainUndefine with snapshots is more reasonable,
but I think its still possible to argue that it should be allowed
and that a later virDomainDefine with the same name+uuid should
resurrect any previous snapshots.
13 years, 3 months
[libvirt] [PATCH 1/2] Fix keymap used to talk with QEMU
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
The QEMU 'sendkey' command expects keys to be encoded in the same
way as the RFB extended keycode set. Specfically it wants extended
keys to have the high bit of the first byte set, while the Linux
XT KBD driver codeset uses the low bit of the second byte. To deal
with this we introduce a new keymap 'RFB' and use that in the QEMU
driver
* include/libvirt/libvirt.h.in: Add VIR_KEYCODE_SET_RFB
* src/qemu/qemu_driver.c: Use RFB keycode set instead of XT KBD
* src/util/virkeycode-mapgen.py: Auto-generate the RFB keycode
set from the XT KBD set
* src/util/virkeycode.c: Add RFB keycode entry to table. Add a
verify check on cardinality of the codeOffset table
---
include/libvirt/libvirt.h.in | 1 +
src/qemu/qemu_driver.c | 8 ++++----
src/util/virkeycode-mapgen.py | 12 ++++++++++++
src/util/virkeycode.c | 5 +++++
4 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index aa29fb6..53a2f7d 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -1875,6 +1875,7 @@ typedef enum {
VIR_KEYCODE_SET_XT_KBD = 6,
VIR_KEYCODE_SET_USB = 7,
VIR_KEYCODE_SET_WIN32 = 8,
+ VIR_KEYCODE_SET_RFB = 9,
VIR_KEYCODE_SET_LAST,
} virKeycodeSet;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 57ad3d1..4ede142 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1883,17 +1883,17 @@ static int qemuDomainSendKey(virDomainPtr domain,
virCheckFlags(0, -1);
- /* translate the keycode to XT_KBD for qemu driver */
- if (codeset != VIR_KEYCODE_SET_XT_KBD) {
+ /* translate the keycode to RFB for qemu driver */
+ if (codeset != VIR_KEYCODE_SET_RFB) {
int i;
int keycode;
for (i = 0; i < nkeycodes; i++) {
- keycode = virKeycodeValueTranslate(codeset, VIR_KEYCODE_SET_XT_KBD,
+ keycode = virKeycodeValueTranslate(codeset, VIR_KEYCODE_SET_RFB,
keycodes[i]);
if (keycode < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
- _("cannot translate keycode %u of %s codeset to xt_kbd keycode"),
+ _("cannot translate keycode %u of %s codeset to rfb keycode"),
keycodes[i],
virKeycodeSetTypeToString(codeset));
return -1;
diff --git a/src/util/virkeycode-mapgen.py b/src/util/virkeycode-mapgen.py
index acf7364..d3d2aae 100755
--- a/src/util/virkeycode-mapgen.py
+++ b/src/util/virkeycode-mapgen.py
@@ -14,6 +14,7 @@ import sys
import re
namecolums = (0,2,10)
+xtkbdkey_index = 8
def quotestring(str):
if str[0] != '"':
@@ -35,10 +36,21 @@ sys.stdin.readline() # eat the fist line.
for line in sys.stdin.xreadlines():
a = re.match("([^,]*)," * 13 + "([^,]*)$", line[0:-1]).groups()
b = ""
+ rfbkey = 0
for i in namecolums:
b = b + (a[i] and quotestring(a[i]) or 'NULL') + ','
for i in [ x for x in range(12) if not x in namecolums ]:
b = b + (a[i] or '0') + ','
+ if i == xtkbdkey_index:
+ # RFB keycodes are XT kbd keycodes with a slightly
+ # different encoding of 0xe0 scan codes. RFB uses
+ # the high bit of the first byte, instead of the low
+ # bit of the second byte.
+ rfbkey = int(a[i] or '0')
+ rfbkey = (rfbkey & 0x100) >> 1 | (rfbkey & 0x7f)
+
+ # Append RFB keycode as the last column
+ b = b + str(rfbkey)
print " { " + b + "},"
print '};'
diff --git a/src/util/virkeycode.c b/src/util/virkeycode.c
index 0d42767..de7aa81 100644
--- a/src/util/virkeycode.c
+++ b/src/util/virkeycode.c
@@ -38,6 +38,7 @@ struct keycode {
unsigned short xt_kbd;
unsigned short usb;
unsigned short win32;
+ unsigned short rfb;
};
#define VIRT_KEY_INTERNAL
@@ -62,7 +63,10 @@ static unsigned int codeOffset[] = {
offsetof(struct keycode, usb),
[VIR_KEYCODE_SET_WIN32] =
offsetof(struct keycode, win32),
+ [VIR_KEYCODE_SET_RFB] =
+ offsetof(struct keycode, rfb),
};
+extern int (*codeOffsetVerify(void)) [verify_true (ARRAY_CARDINALITY(codeOffset) == VIR_KEYCODE_SET_LAST)]; \
VIR_ENUM_IMPL(virKeycodeSet, VIR_KEYCODE_SET_LAST,
"linux",
@@ -74,6 +78,7 @@ VIR_ENUM_IMPL(virKeycodeSet, VIR_KEYCODE_SET_LAST,
"xt_kbd",
"usb",
"win32",
+ "rfb",
);
static int __virKeycodeValueFromString(unsigned int name_offset,
--
1.7.6
13 years, 3 months
[libvirt] [PATCH 1/2] virterror: Fix error message for VIR_ERR_INVALID_ARG
by Michal Privoznik
When a detail message is presented, nobody expects prefix 'invalid
argument in' but something more general, like 'invalid argument:'.
---
src/util/virterror.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/util/virterror.c b/src/util/virterror.c
index c5babb1..f4541bd 100644
--- a/src/util/virterror.c
+++ b/src/util/virterror.c
@@ -794,7 +794,7 @@ virErrorMsg(virErrorNumber error, const char *info)
if (info == NULL)
errmsg = _("invalid argument in");
else
- errmsg = _("invalid argument in %s");
+ errmsg = _("invalid argument: %s");
break;
case VIR_ERR_OPERATION_FAILED:
if (info != NULL)
--
1.7.3.4
13 years, 3 months