[libvirt] [RFC PATCHv2 0/5] Smartcard support
by Eric Blake
Posting now, even though the patch series is not quite polished
(still lacking a final test), in order to start the review
cycle.
Eric Blake (5):
domain_conf: split source data out from ChrDef
qemu: move monitor device out of domain_conf common code
smartcard: add XML support for <smartcard> device
smartcard: add domain conf support
WIP: smartcard: turn on qemu support
cfg.mk | 2 +
docs/formatdomain.html.in | 72 +++
docs/schemas/domain.rng | 37 ++
src/conf/domain_conf.c | 567 +++++++++++++++-----
src/conf/domain_conf.h | 82 +++-
src/libvirt_private.syms | 5 +
src/lxc/lxc_driver.c | 12 +-
src/qemu/qemu_cgroup.c | 10 +-
src/qemu/qemu_command.c | 181 ++++---
src/qemu/qemu_command.h | 9 +-
src/qemu/qemu_domain.c | 11 +-
src/qemu/qemu_domain.h | 4 +-
src/qemu/qemu_driver.c | 50 +-
src/qemu/qemu_hotplug.c | 2 +-
src/qemu/qemu_monitor.c | 4 +-
src/qemu/qemu_monitor.h | 4 +-
src/security/security_dac.c | 8 +-
src/security/security_selinux.c | 10 +-
src/security/virt-aa-helper.c | 42 +-
src/uml/uml_conf.c | 16 +-
src/uml/uml_driver.c | 14 +-
src/vbox/vbox_tmpl.c | 49 +-
src/vmx/vmx.c | 84 ++--
src/xen/xen_driver.c | 6 +-
src/xen/xend_internal.c | 87 ++--
.../qemuxml2argv-smartcard-host-certificates.xml | 20 +
.../qemuxml2argv-smartcard-host.xml | 16 +
.../qemuxml2argv-smartcard-passthrough-tcp.xml | 19 +
tests/qemuxml2argvtest.c | 5 +-
29 files changed, 997 insertions(+), 431 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-smartcard-host-certificates.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-smartcard-host.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough-tcp.xml
--
1.7.3.4
13 years, 11 months
[libvirt] [PATCH v2] qemu: Warning prompt if invalid dump image format specified
by Osier Yang
"getCompressionType" trys to throw error when invalid dump image
format is specified, or the compression program for the specified
image format is not available, but at the same time, it returns
enum qemud_save_formats, as a result, upper function will think
it was successful, and disgard to check the error.
Change "qemuReportError" into "VIR_WARN" instead to let the user
known what happened.
v1 patch is here:
http://www.redhat.com/archives/libvir-list/2011-January/msg00715.html
As it reverted b6f13bb7002da76db15242e1d996e8a6222a754, and it was
intentionally to chose the behavior of falling back to raw if the
compression type is invalid, so simply use "VIR_WARN" to fix the
problem.
* src/qemu/qemu_driver.c
---
src/qemu/qemu_driver.c | 13 ++++++-------
1 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 34cc29f..dac71fa 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4806,16 +4806,15 @@ getCompressionType(struct qemud_driver *driver)
if (driver->dumpImageFormat) {
compress = qemudSaveCompressionTypeFromString(driver->dumpImageFormat);
if (compress < 0) {
- qemuReportError(VIR_ERR_OPERATION_FAILED, "%s",
- _("Invalid dump image format specified in "
- "configuration file, using raw"));
+ VIR_WARN("Invalid dump image format '%s' specified in "
+ "configuration file, using raw",
+ driver->dumpImageFormat);
return QEMUD_SAVE_FORMAT_RAW;
}
if (!qemudCompressProgramAvailable(compress)) {
- qemuReportError(VIR_ERR_OPERATION_FAILED,
- "%s", _("Compression program for dump image format "
- "in configuration file isn't available, "
- "using raw"));
+ VIR_WARN("Compression program for dump image format '%s' "
+ "in configuration file isn't available, using raw",
+ driver->dumpImageFormat);
return QEMUD_SAVE_FORMAT_RAW;
}
}
--
1.7.3.2
13 years, 11 months
[libvirt] Domain callback, the new way
by arnaud.champion@devatom.fr
?Hi,
I'm working on c# bindings, on domain callback. I have successfully binded the old way to manage callbacks via the old virConnectDomainEventRegister function. Now I'm trying to work with the new API contract with virConnectDomainEventRegisterAny... I'm looking for a sample (in C for exemple) to see how using these functions, can anyone can explain me how this work ?
Regards,
Arnaud
13 years, 11 months
[libvirt] [PATCH 1/1] Do not use virtio-serial port 0 for generic ports
by David Allan
Per the discussion in:
https://bugzilla.redhat.com/show_bug.cgi?id=670394
The port numbering should start from 1, not 0. We assign maxport + 1,
so start maxport at 0.
---
src/conf/domain_conf.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d5445a4..08c21e5 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5328,7 +5328,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
if (chr->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL &&
chr->info.addr.vioserial.port == 0) {
- int maxport = -1;
+ int maxport = 0;
int j;
for (j = 0 ; j < i ; j++) {
virDomainChrDefPtr thischr = def->channels[j];
--
1.7.3.4
13 years, 11 months
[libvirt] [PATCH] Imprint all logs with version + package build information
by Daniel P. Berrange
The logging functions are enhanced so that immediately prior to
the first log message being printed to any output channel, the
libvirt package version will be printed.
eg
$ LIBVIRT_DEBUG=1 virsh
18:13:28.013: 17536: info : libvirt version: 0.8.7
18:13:28.013: 17536: debug : virInitialize:361 : register drivers
...
The 'configure' script gains a '--with-package-string' argument
to allow distros to append a custom string with package specific
data.
The RPM specfile is modified so that it appends the RPM version,
the build host, the build date and the packager name.
eg
$ LIBVIRT_DEBUG=1 virsh
18:14:52.086: 17551: info : libvirt version: 0.8.7, package: 1.fc13 (Fedora Project, x86-01.phx2.fedoraproject.org, 01-27-2011-18:00:10)
18:14:52.086: 17551: debug : virInitialize:361 : register drivers
Thus when distro packagers receive bug reports they can clearly
see what version was in use, even if the bug reporter mistakenly
or intentionally lies about version/builds
* src/util/logging.c: Output version data prior to first log message
* libvirt.spec.in: Include RPM release, date, hostname & packager
* configure.ac: Add --with-package-string arg
---
configure.ac | 10 ++++++
libvirt.spec.in | 7 ++++
src/util/logging.c | 86 +++++++++++++++++++++++++++++++++++++++++++---------
3 files changed, 88 insertions(+), 15 deletions(-)
diff --git a/configure.ac b/configure.ac
index f310a5e..92d77e4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -29,6 +29,16 @@ AC_SUBST([LIBVIRT_VERSION])
AC_SUBST([LIBVIRT_VERSION_INFO])
AC_SUBST([LIBVIRT_VERSION_NUMBER])
+AC_ARG_WITH([package-string],
+ [AS_HELP_STRING([--with-package-string],
+ [Extra package name/version string])],
+ [],[])
+if test "x$with_package_string" != "xno"
+then
+ AC_DEFINE_UNQUOTED([PACKAGE_STRING], ["$with_package_string"],
+ [Extra package name/version string])
+fi
+
dnl Required minimum versions of all libs we depend on
LIBXML_REQUIRED="2.6.0"
GNUTLS_REQUIRED="1.0.25"
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 0a2d10e..43c9067 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -592,6 +592,12 @@ of recent versions of Linux (and other OSes).
%define _without_dtrace --without-dtrace
%endif
+%define when %(date +"%%m-%%d-%%Y-%%H:%%M:%%S")
+%define where %(hostname)
+%define who %{?packager}%{!?packager:Unknown}
+%define with_package_string --with-package-string="%{release} (%{who}, %{when}, %{where})"
+
+
%configure %{?_without_xen} \
%{?_without_qemu} \
%{?_without_openvz} \
@@ -626,6 +632,7 @@ of recent versions of Linux (and other OSes).
%{?_without_macvtap} \
%{?_without_audit} \
%{?_without_dtrace} \
+ %{with_package_string} \
--with-qemu-user=%{qemu_user} \
--with-qemu-group=%{qemu_group} \
--with-init-script=redhat \
diff --git a/src/util/logging.c b/src/util/logging.c
index a80c3e3..5102e06 100644
--- a/src/util/logging.c
+++ b/src/util/logging.c
@@ -108,6 +108,7 @@ static int virLogNbFilters = 0;
* after filtering, multiple output can be used simultaneously
*/
struct _virLogOutput {
+ bool logVersion;
void *data;
virLogOutputFunc f;
virLogCloseFunc c;
@@ -490,6 +491,7 @@ int virLogDefineOutput(virLogOutputFunc f, virLogCloseFunc c, void *data,
goto cleanup;
}
ret = virLogNbOutputs++;
+ virLogOutputs[ret].logVersion = true;
virLogOutputs[ret].f = f;
virLogOutputs[ret].c = c;
virLogOutputs[ret].data = data;
@@ -501,6 +503,50 @@ cleanup:
return ret;
}
+static int
+virLogFormatString(char **msg,
+ const char *funcname,
+ long long linenr,
+ struct tm *time_info,
+ struct timeval *cur_time,
+ int priority,
+ const char *str)
+{
+ int ret;
+ if ((funcname != NULL)) {
+ ret = virAsprintf(msg, "%02d:%02d:%02d.%03d: %d: %s : %s:%lld : %s\n",
+ time_info->tm_hour, time_info->tm_min,
+ time_info->tm_sec, (int) cur_time->tv_usec / 1000,
+ virThreadSelfID(),
+ virLogPriorityString(priority), funcname, linenr, str);
+ } else {
+ ret = virAsprintf(msg, "%02d:%02d:%02d.%03d: %d: %s : %s\n",
+ time_info->tm_hour, time_info->tm_min,
+ time_info->tm_sec, (int) cur_time->tv_usec / 1000,
+ virThreadSelfID(),
+ virLogPriorityString(priority), str);
+ }
+ return ret;
+}
+
+static int
+virLogVersionString(char **msg,
+ struct tm *time_info,
+ struct timeval *cur_time)
+{
+#ifdef PACKAGE_STRING
+# define LOG_VERSION_STRING \
+ "libvirt version: " VERSION ", package: " PACKAGE_STRING
+#else
+# define LOG_VERSION_STRING \
+ "libvirt version: " VERSION
+#endif
+
+ return virLogFormatString(msg, NULL, 0,
+ time_info, cur_time,
+ VIR_LOG_INFO, LOG_VERSION_STRING);
+}
+
/**
* virLogMessage:
* @category: where is that message coming from
@@ -516,6 +562,7 @@ cleanup:
*/
void virLogMessage(const char *category, int priority, const char *funcname,
long long linenr, int flags, const char *fmt, ...) {
+ static bool logVersionStderr = true;
char *str = NULL;
char *msg;
struct timeval cur_time;
@@ -547,19 +594,9 @@ void virLogMessage(const char *category, int priority, const char *funcname,
gettimeofday(&cur_time, NULL);
localtime_r(&cur_time.tv_sec, &time_info);
- if ((funcname != NULL)) {
- ret = virAsprintf(&msg, "%02d:%02d:%02d.%03d: %d: %s : %s:%lld : %s\n",
- time_info.tm_hour, time_info.tm_min,
- time_info.tm_sec, (int) cur_time.tv_usec / 1000,
- virThreadSelfID(),
- virLogPriorityString(priority), funcname, linenr, str);
- } else {
- ret = virAsprintf(&msg, "%02d:%02d:%02d.%03d: %d: %s : %s\n",
- time_info.tm_hour, time_info.tm_min,
- time_info.tm_sec, (int) cur_time.tv_usec / 1000,
- virThreadSelfID(),
- virLogPriorityString(priority), str);
- }
+ ret = virLogFormatString(&msg, funcname, linenr,
+ &time_info, &cur_time,
+ priority, str);
VIR_FREE(str);
if (ret < 0) {
/* apparently we're running out of memory */
@@ -578,12 +615,31 @@ void virLogMessage(const char *category, int priority, const char *funcname,
virLogStr(msg, len);
virLogLock();
for (i = 0; i < virLogNbOutputs;i++) {
- if (priority >= virLogOutputs[i].priority)
+ if (priority >= virLogOutputs[i].priority) {
+ if (virLogOutputs[i].logVersion) {
+ char *ver = NULL;
+ if (virLogVersionString(&ver, &time_info, &cur_time) >= 0)
+ virLogOutputs[i].f(category, priority, __func__, __LINE__,
+ ver, strlen(ver),
+ virLogOutputs[i].data);
+ VIR_FREE(ver);
+ virLogOutputs[i].logVersion = false;
+ }
virLogOutputs[i].f(category, priority, funcname, linenr,
msg, len, virLogOutputs[i].data);
+ }
}
- if ((virLogNbOutputs == 0) && (flags != 1))
+ if ((virLogNbOutputs == 0) && (flags != 1)) {
+ if (logVersionStderr) {
+ char *ver = NULL;
+ if (virLogVersionString(&ver, &time_info, &cur_time) >= 0)
+ ignore_value (safewrite(STDERR_FILENO,
+ ver, strlen(ver)));
+ VIR_FREE(ver);
+ logVersionStderr = false;
+ }
ignore_value (safewrite(STDERR_FILENO, msg, len));
+ }
virLogUnlock();
VIR_FREE(msg);
--
1.7.3.4
13 years, 11 months
[libvirt] [PATCH] Remove bogus log warning lines when launching QEMU
by Daniel P. Berrange
The refactoring of QEMU command startup was comitted with
a couple of VIR_WARN lines left in from debugging.
* src/qemu/qemu_driver.c: Remove log warning lines
---
src/qemu/qemu_driver.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 98eb91f..2e8f4f9 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2865,7 +2865,6 @@ static int qemudStartVMDaemon(virConnectPtr conn,
if (driver->clearEmulatorCapabilities)
virCommandClearCaps(cmd);
- VIR_WARN("Executing %s", vm->def->emulator);
virCommandSetPreExecHook(cmd, qemudSecurityHook, &hookData);
virCommandSetOutputFD(cmd, &logfile);
@@ -2875,7 +2874,6 @@ static int qemudStartVMDaemon(virConnectPtr conn,
virCommandDaemonize(cmd);
ret = virCommandRun(cmd, NULL);
- VIR_WARN("Executing done %s", vm->def->emulator);
VIR_FREE(pidfile);
/* wait for qemu process to to show up */
--
1.7.3.4
13 years, 11 months
[libvirt] [PATCH] Remove double close of qemu monitor
by Daniel P. Berrange
When qemuMonitorSetCapabilities() fails, there is no need to
call qemuMonitorClose(), because the caller will already see
the error code and tear down the entire VM. The extra call to
qemuMonitorClose resulted in a double-free due to it removing
a ref count prematurely.
* src/qemu/qemu_driver.c: Remove premature close of monitor
---
src/qemu/qemu_driver.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 3b937e4..2e8f4f9 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -900,8 +900,6 @@ qemuConnectMonitor(struct qemud_driver *driver, virDomainObjPtr vm)
qemuDomainObjExitMonitorWithDriver(driver, vm);
error:
- if (ret < 0)
- qemuMonitorClose(priv->mon);
return ret;
}
--
1.7.3.4
13 years, 11 months
[libvirt] [PATCH] Remove bogus log warning lines when launching QEMU
by Daniel P. Berrange
The refactoring of QEMU command startup was comitted with
a couple of VIR_WARN lines left in from debugging.
* src/qemu/qemu_driver.c: Remove log warning lines
---
src/qemu/qemu_driver.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 98eb91f..2e8f4f9 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2865,7 +2865,6 @@ static int qemudStartVMDaemon(virConnectPtr conn,
if (driver->clearEmulatorCapabilities)
virCommandClearCaps(cmd);
- VIR_WARN("Executing %s", vm->def->emulator);
virCommandSetPreExecHook(cmd, qemudSecurityHook, &hookData);
virCommandSetOutputFD(cmd, &logfile);
@@ -2875,7 +2874,6 @@ static int qemudStartVMDaemon(virConnectPtr conn,
virCommandDaemonize(cmd);
ret = virCommandRun(cmd, NULL);
- VIR_WARN("Executing done %s", vm->def->emulator);
VIR_FREE(pidfile);
/* wait for qemu process to to show up */
--
1.7.3.4
13 years, 11 months
[libvirt] beginner's project
by Eric Blake
This idea sprang from an IRC conversation, but I don't have time to do
it myself at the moment. If you're looking for a great way to help
development, it would be nice to teach
tests/testutils.c:virtTestLoadFile
how to read a file with backslash-newline pairs and flatten those into a
single line.
Then rewrite all the tests/*data/*.args files to use line continuations,
rather than being monstrous 1000-character lines.
That way, git send-email will quit griping about the inability to send
patches to those files.
--
Eric Blake eblake(a)redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
13 years, 11 months
[libvirt] [PATCH] docs: expand the man page text for virsh setmaxmem
by Justin Clift
Addresses BZ # 622534:
https://bugzilla.redhat.com/show_bug.cgi?id=622534
---
tools/virsh.pod | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 4e8b295..0d37512 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -584,9 +584,20 @@ update the XML <currentMemory> element.
=item B<setmaxmem> I<domain-id> B<kilobytes>
-Change the maximum memory allocation limit in the guest domain. This should
-not change the current memory use. The memory limit is specified in
-kilobytes.
+Change the maximum memory allocation limit for an inactive guest domain.
+
+This command works for at least the Xen and vSphere/ESX hypervisors,
+but not for QEMU/KVM.
+
+Some hypervisors require a larger granularity than kilobytes, rounding down
+or rejecting requests that are not an even multiple of the desired amount.
+vSphere/ESX is one of these, requiring the parameter to be evenly divisible
+by 4MB. For example with vSphere/ESX, 262144 (256MB) is valid as it's a
+multiple of 4MB; 263168 (257MB) is not valid as it's not a multiple of 4MB;
+266240 (260MB) is also valid, as it's a multiple of 4MB.
+
+Note, to change the maximum memory allocation for a QEMU/KVM guest domain,
+use the virsh B<edit> command instead to update its XML <memory> element.
=item B<memtune> I<domain-id> optional I<--hard-limit> B<kilobytes>
optional I<--soft-limit> B<kilobytes> optional I<--swap-hard-limit>
--
1.7.3.5
13 years, 11 months