[libvirt] [PATCH v4 0/2] qemu: Support for QXL heads
by Martin Kletzander
v4:
- Added test case without "heads="
- Don't consolidate 'size_t i, j' declarations
v3:
- https://www.redhat.com/archives/libvir-list/2016-March/msg01198.html
- rebase on top of current master in order to cleanly apply
v2:
- don't change heads when migrating
- https://www.redhat.com/archives/libvir-list/2016-March/msg00811.html
v1:
- https://www.redhat.com/archives/libvir-list/2016-March/msg00410.html
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1283207
Martin Kletzander (2):
qemu: Check for qxl's max_outputs parameter
qemu: Add support to QXL's max_outputs parameter
src/qemu/qemu_capabilities.c | 4 ++
src/qemu/qemu_capabilities.h | 2 +
src/qemu/qemu_command.c | 8 +++
src/qemu/qemu_migration.c | 64 ++++++++++++++++++++--
.../qemuhotplug-agent-nopath.xml | 5 ++
.../qemuhotplug-hotplug-base+agent-nopath.xml | 58 ++++++++++++++++++++
.../qemuxml2argv-video-qxl-heads.args | 28 ++++++++++
.../qemuxml2argv-video-qxl-heads.xml | 47 ++++++++++++++++
.../qemuxml2argv-video-qxl-noheads.args | 24 ++++++++
.../qemuxml2argv-video-qxl-noheads.xml | 39 +++++++++++++
tests/qemuxml2argvtest.c | 16 ++++++
.../qemuxml2xmlout-video-qxl-heads.xml | 47 ++++++++++++++++
.../qemuxml2xmlout-video-qxl-noheads.xml | 39 +++++++++++++
tests/qemuxml2xmltest.c | 3 +
14 files changed, 379 insertions(+), 5 deletions(-)
create mode 100644 tests/qemuhotplugtestdata/qemuhotplug-agent-nopath.xml
create mode 100644 tests/qemuhotplugtestdata/qemuhotplug-hotplug-base+agent-nopath.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-qxl-heads.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-qxl-heads.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-qxl-noheads.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-qxl-noheads.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-video-qxl-heads.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-video-qxl-noheads.xml
--
2.8.0
8 years, 8 months
[libvirt] [PATCH 0/3] some additional hyper-v features fixes
by Pavel Hrdina
Pavel Hrdina (3):
docs: fix qemu version for hyperv features
qemu_process: skip only cpu features
qemu_process: add check for hyperv features
docs/formatdomain.html.in | 4 ++--
src/cpu/cpu_x86.c | 8 +++++++
src/cpu/cpu_x86_data.h | 8 +++++++
src/qemu/qemu_process.c | 57 +++++++++++++++++++++++++++++++++++------------
4 files changed, 61 insertions(+), 16 deletions(-)
--
2.7.4
8 years, 8 months
[libvirt] [PATCH V4 0/6] libxl: support assign VF to guest from SRIOV pool
by Chunyan Liu
This patch series is to support assign VF to guest from SRIOV pool,
including fixes to network attach/detach and fix to libxlDomainstart.
Chunyan Liu (6):
libxlDomainAttachNetDevice: release actual deivce and remove hostdev
when fail
libxlDomainDetachNetDevice: cleanup codes
libxlDomainDetachDeviceLive: handle hostdev parent is network device
libxl: support creating domain with VF assignment from a pool
libxl: fix hot add/remove VF from a pool
libxlDomainStart: correct cleanup after failure
src/libxl/libxl_domain.c | 85 +++++++++++++++++++++++++++++++++++++++---------
src/libxl/libxl_driver.c | 52 ++++++++++++++++++++---------
tests/Makefile.am | 3 ++
3 files changed, 108 insertions(+), 32 deletions(-)
--
2.1.4
8 years, 8 months
[libvirt] [PATCH] host-validate: Fix suggestion for missing cpu cgroup
by Andrea Bolognani
If the cpu cgroup is not found when validating an host for
LXC support, virt-host-validate will suggest to enable the
CONFIG_CGROUP_SCHED kconfig option.
The appropriate option is really CONFIG_CGROUP_CPU. The
QEMU checks already get that right, so no changes needed.
---
tools/virt-host-validate-lxc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/virt-host-validate-lxc.c b/tools/virt-host-validate-lxc.c
index 89a6388..2b906cc 100644
--- a/tools/virt-host-validate-lxc.c
+++ b/tools/virt-host-validate-lxc.c
@@ -70,7 +70,7 @@ int virHostValidateLXC(void)
if (virHostValidateCGroupController("LXC", "cpu",
VIR_HOST_VALIDATE_FAIL,
- "CGROUP_SCHED") < 0)
+ "CGROUP_CPU") < 0)
ret = -1;
if (virHostValidateCGroupController("LXC", "cpuacct",
--
2.5.5
8 years, 8 months
[libvirt] [PATCH v2] nss: FreeBSD support
by Roman Bogorodskiy
* tools/nss/libvirt_nss.[ch]: add BSD-comptabile wrappers and
register via the nss_module_register() interface
* m4/virt-nss.m4: add checks if we're building NSS for FreeBSD
* tools/Makefile.am: handle target library name differences, as
Linux needs libnss_libvirt.so.2 and FreeBSD needs
nss_libvirt.so.1. Also, different syms files have to be used
as Linux needs to export all the methods while FreeBSD
only needs to have nss_module_register()
* tests/nsstest.c, tests/nssmock.c: s/__linux__/NSS/
* libvirt_nss_bsd.syms: FreeBSD syms file
---
m4/virt-nss.m4 | 18 +++++-
tests/nssmock.c | 6 +-
tests/nsstest.c | 2 +-
tools/Makefile.am | 16 ++++-
tools/nss/libvirt_nss.c | 139 +++++++++++++++++++++++++++++++++++++++--
tools/nss/libvirt_nss.h | 9 +++
tools/nss/libvirt_nss_bsd.syms | 9 +++
7 files changed, 189 insertions(+), 10 deletions(-)
create mode 100644 tools/nss/libvirt_nss_bsd.syms
diff --git a/m4/virt-nss.m4 b/m4/virt-nss.m4
index 3fa4ad3..3d6e8f4 100644
--- a/m4/virt-nss.m4
+++ b/m4/virt-nss.m4
@@ -23,6 +23,7 @@ AC_DEFUN([LIBVIRT_CHECK_NSS],[
[enable Name Servie Switch plugin for resolving guest IP addresses])],
[], [with_nss_plugin=check])
+ bsd_nss=no
fail=0
if test "x$with_nss_plugin" != "xno" ; then
AC_CHECK_HEADERS([nss.h], [
@@ -39,11 +40,26 @@ AC_DEFUN([LIBVIRT_CHECK_NSS],[
if test "x$with_nss_plugin" = "xyes" ; then
AC_DEFINE_UNQUOTED([NSS], 1, [whether nss plugin is enabled])
+
+ AC_CHECK_TYPE([struct gaih_addrtuple],
+ [AC_DEFINE([HAVE_STRUCT_GAIH_ADDRTUPLE], [1],
+ [Defined if struct gaih_addrtuple exists in nss.h])],
+ [], [[#include <nss.h>
+ ]])
+
+ AC_CHECK_TYPES([ns_mtab, nss_module_unregister_fn],
+ [AC_DEFINE([HAVE_BSD_NSS],
+ [1],
+ [whether using BSD style NSS])
+ bsd_nss=yes
+ ],
+ [],
+ [#include <nsswitch.h>])
fi
fi
AM_CONDITIONAL(WITH_NSS, [test "x$with_nss_plugin" = "xyes"])
-
+ AM_CONDITIONAL(WITH_BSD_NSS, [test "x$bsd_nss" = "xyes"])
])
AC_DEFUN([LIBVIRT_RESULT_NSS],[
diff --git a/tests/nssmock.c b/tests/nssmock.c
index b4a4260..31b1177 100644
--- a/tests/nssmock.c
+++ b/tests/nssmock.c
@@ -20,7 +20,7 @@
#include <config.h>
-#ifdef __linux__
+#ifdef NSS
# include <stdio.h>
# include <stdlib.h>
# include <dlfcn.h>
@@ -107,7 +107,7 @@ open(const char *path, int flags, ...)
va_list ap;
mode_t mode;
va_start(ap, flags);
- mode = va_arg(ap, mode_t);
+ mode = va_arg(ap, int);
va_end(ap);
ret = realopen(newpath ? newpath : path, flags, mode);
} else {
@@ -136,5 +136,5 @@ opendir(const char *path)
return ret;
}
#else
-/* Nothing to override on non-__linux__ platforms */
+/* Nothing to override if NSS plugin is not enabled */
#endif
diff --git a/tests/nsstest.c b/tests/nsstest.c
index 7399d9a..63c7162 100644
--- a/tests/nsstest.c
+++ b/tests/nsstest.c
@@ -22,7 +22,7 @@
#include "testutils.h"
-#ifdef __linux__
+#ifdef NSS
# include <stdbool.h>
# include <arpa/inet.h>
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 4320040..6005b8b 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -417,8 +417,22 @@ CLEANFILES += wireshark/src/plugin.c
endif WITH_WIRESHARK_DISSECTOR
+if WITH_BSD_NSS
+LIBVIRT_NSS_SYMBOL_FILE = \
+ $(srcdir)/nss/libvirt_nss_bsd.syms
+NSS_SO_VER = 1
+
+install-exec-hook:
+ cd $(DESTDIR)$(libdir) && \
+ $(LN_S) libnss_libvirt.so.$(NSS_SO_VER) nss_libvirt.so.$(NSS_SO_VER)
+
+uninstall-local:
+ rm $(DESTDIR)$(libdir)/libnss_libvirt.so.$(NSS_SO_VER)
+else ! WITH_BSD_NSS
LIBVIRT_NSS_SYMBOL_FILE = \
$(srcdir)/nss/libvirt_nss.syms
+NSS_SO_VER = 2
+endif ! WITH_BSD_NSS
LIBVIRT_NSS_SOURCES = \
nss/libvirt_nss.c \
@@ -449,7 +463,7 @@ nss_libnss_libvirt_la_LDFLAGS = \
-export-dynamic \
-avoid-version \
-shared \
- -shrext .so.2
+ -shrext .so.$(NSS_SO_VER)
nss_libnss_libvirt_la_LIBADD = \
nss/libnss_libvirt_impl.la
diff --git a/tools/nss/libvirt_nss.c b/tools/nss/libvirt_nss.c
index 218c62a..de34baf 100644
--- a/tools/nss/libvirt_nss.c
+++ b/tools/nss/libvirt_nss.c
@@ -29,11 +29,16 @@
#include "libvirt_nss.h"
+#include <netinet/in.h>
#include <resolv.h>
#include <sys/types.h>
#include <dirent.h>
#include <arpa/inet.h>
+#if defined(HAVE_BSD_NSS)
+# include <nsswitch.h>
+#endif
+
#include "virlease.h"
#include "viralloc.h"
#include "virfile.h"
@@ -65,7 +70,7 @@ do { \
#define LEASEDIR LOCALSTATEDIR "/lib/libvirt/dnsmasq/"
-#define ALIGN(x) (((x) + __SIZEOF_POINTER__ - 1) & ~(__SIZEOF_POINTER__ - 1))
+#define LIBVIRT_ALIGN(x) (((x) + __SIZEOF_POINTER__ - 1) & ~(__SIZEOF_POINTER__ - 1))
#define FAMILY_ADDRESS_SIZE(family) ((family) == AF_INET6 ? 16 : 4)
typedef struct {
@@ -256,7 +261,7 @@ static inline void *
move_and_align(void *buf, size_t len, size_t *idx)
{
char *buffer = buf;
- size_t move = ALIGN(len);
+ size_t move = LIBVIRT_ALIGN(len);
if (!idx)
return buffer + move;
@@ -321,7 +326,7 @@ _nss_libvirt_gethostbyname3_r(const char *name, int af, struct hostent *result,
* b) alias
* c) addresses
* d) NULL stem */
- need = ALIGN(nameLen + 1) + naddr * ALIGN(alen) + (naddr + 2) * sizeof(char*);
+ need = LIBVIRT_ALIGN(nameLen + 1) + naddr * LIBVIRT_ALIGN(alen) + (naddr + 2) * sizeof(char*);
if (buflen < need) {
*errnop = ENOMEM;
@@ -383,6 +388,7 @@ _nss_libvirt_gethostbyname3_r(const char *name, int af, struct hostent *result,
return ret;
}
+#ifdef HAVE_STRUCT_GAIH_ADDRTUPLE
enum nss_status
_nss_libvirt_gethostbyname4_r(const char *name, struct gaih_addrtuple **pat,
char *buffer, size_t buflen, int *errnop,
@@ -426,7 +432,7 @@ _nss_libvirt_gethostbyname4_r(const char *name, struct gaih_addrtuple **pat,
/* We need space for:
* a) name
* b) addresses */
- need = ALIGN(nameLen + 1) + naddr * ALIGN(sizeof(struct gaih_addrtuple));
+ need = LIBVIRT_ALIGN(nameLen + 1) + naddr * LIBVIRT_ALIGN(sizeof(struct gaih_addrtuple));
if (buflen < need) {
*errnop = ENOMEM;
@@ -474,3 +480,128 @@ _nss_libvirt_gethostbyname4_r(const char *name, struct gaih_addrtuple **pat,
cleanup:
return ret;
}
+#endif /* HAVE_STRUCT_GAIH_ADDRTUPLE */
+
+#if defined(HAVE_BSD_NSS)
+NSS_METHOD_PROTOTYPE(_nss_compat_getaddrinfo);
+NSS_METHOD_PROTOTYPE(_nss_compat_gethostbyname2_r);
+
+ns_mtab methods[] = {
+ { NSDB_HOSTS, "getaddrinfo", _nss_compat_getaddrinfo, NULL },
+ { NSDB_HOSTS, "gethostbyname", _nss_compat_gethostbyname2_r, NULL },
+ { NSDB_HOSTS, "gethostbyname2_r", _nss_compat_gethostbyname2_r, NULL },
+};
+
+static void
+aiforaf(const char *name, int af, struct addrinfo *pai, struct addrinfo **aip)
+{
+ int ret;
+ struct hostent resolved;
+ char buf[1024] = { 0 };
+ int err, herr;
+ struct addrinfo hints, *res0, *res;
+ char **addrList;
+
+ if ((ret = _nss_libvirt_gethostbyname2_r(name, af, &resolved,
+ buf, sizeof(buf),
+ &err, &herr)) != NS_SUCCESS)
+ return;
+
+ addrList = resolved.h_addr_list;
+ while (*addrList) {
+ virSocketAddr sa;
+ char *ipAddr = NULL;
+ void *address = *addrList;
+
+ memset(&sa, 0, sizeof(sa));
+ if (resolved.h_addrtype == AF_INET) {
+ virSocketAddrSetIPv4AddrNetOrder(&sa, *((uint32_t *) address));
+ } else {
+ virSocketAddrSetIPv6AddrNetOrder(&sa, address);
+ }
+
+ ipAddr = virSocketAddrFormat(&sa);
+
+ hints = *pai;
+ hints.ai_flags = AI_NUMERICHOST;
+ hints.ai_family = af;
+
+ if (getaddrinfo(ipAddr, NULL, &hints, &res0)) {
+ addrList++;
+ continue;
+ }
+
+ for (res = res0; res; res = res->ai_next)
+ res->ai_flags = pai->ai_flags;
+
+ (*aip)->ai_next = res0;
+ while ((*aip)->ai_next)
+ *aip = (*aip)->ai_next;
+
+ addrList++;
+ }
+}
+
+int
+_nss_compat_getaddrinfo(void *retval, void *mdata ATTRIBUTE_UNUSED, va_list ap)
+{
+ struct addrinfo sentinel, *cur, *ai;
+ const char *name;
+
+ name = va_arg(ap, char *);
+ ai = va_arg(ap, struct addrinfo *);
+
+ memset(&sentinel, 0, sizeof(sentinel));
+ cur = &sentinel;
+
+ if ((ai->ai_family == AF_UNSPEC) || (ai->ai_family == AF_INET6))
+ aiforaf(name, AF_INET6, ai, &cur);
+ if ((ai->ai_family == AF_UNSPEC) || (ai->ai_family == AF_INET))
+ aiforaf(name, AF_INET, ai, &cur);
+
+ if (sentinel.ai_next == NULL) {
+ h_errno = HOST_NOT_FOUND;
+ return NS_NOTFOUND;
+ }
+ *((struct addrinfo **)retval) = sentinel.ai_next;
+
+ return NS_SUCCESS;
+}
+
+int
+_nss_compat_gethostbyname2_r(void *retval, void *mdata ATTRIBUTE_UNUSED, va_list ap)
+{
+ int ret;
+
+ const char *name;
+ int af;
+ struct hostent *result;
+ char *buffer;
+ size_t buflen;
+ int *errnop;
+ int *herrnop;
+
+ name = va_arg(ap, const char *);
+ af = va_arg(ap, int);
+ result = va_arg(ap, struct hostent *);
+ buffer = va_arg(ap, char *);
+ buflen = va_arg(ap, size_t);
+ errnop = va_arg(ap, int *);
+ herrnop = va_arg(ap, int *);
+
+ ret = _nss_libvirt_gethostbyname2_r(
+ name, af, result, buffer, buflen, errnop, herrnop);
+ *(struct hostent **)retval = (ret == NS_SUCCESS) ? result : NULL;
+
+ return ret;
+}
+
+ns_mtab*
+nss_module_register(const char *name ATTRIBUTE_UNUSED, unsigned int *size,
+ nss_module_unregister_fn *unregister)
+{
+ *size = sizeof(methods) / sizeof(methods[0]);
+ *unregister = NULL;
+ return methods;
+}
+#endif /* HAVE_BSD_NSS */
diff --git a/tools/nss/libvirt_nss.h b/tools/nss/libvirt_nss.h
index 589c1e6..e025e63 100644
--- a/tools/nss/libvirt_nss.h
+++ b/tools/nss/libvirt_nss.h
@@ -45,8 +45,17 @@ enum nss_status
_nss_libvirt_gethostbyname3_r(const char *name, int af, struct hostent *result,
char *buffer, size_t buflen, int *errnop,
int *herrnop, int32_t *ttlp, char **canonp);
+# ifdef HAVE_STRUCT_GAIH_ADDRTUPLE
enum nss_status
_nss_libvirt_gethostbyname4_r(const char *name, struct gaih_addrtuple **pat,
char *buffer, size_t buflen, int *errnop,
int *herrnop, int32_t *ttlp);
+# endif /* HAVE_STRUCT_GAIH_ADDRTUPLE */
+
+# if defined(HAVE_BSD_NSS)
+ns_mtab*
+nss_module_register(const char *name, unsigned int *size,
+ nss_module_unregister_fn *unregister);
+# endif /* HAVE_BSD_NSS */
+
#endif /* __LIBVIRT_NSS_H__ */
diff --git a/tools/nss/libvirt_nss_bsd.syms b/tools/nss/libvirt_nss_bsd.syms
new file mode 100644
index 0000000..7da3926
--- /dev/null
+++ b/tools/nss/libvirt_nss_bsd.syms
@@ -0,0 +1,9 @@
+#
+# Officially exported symbols.
+#
+
+{
+global:
+ nss_module_register;
+local: *;
+};
--
2.7.2
8 years, 8 months
Re: [libvirt] [PATCH 3/3] libxl: only disable domain death events in libxlDomainCleanup
by Jim Fehlig
On 03/28/2016 07:36 PM, Chun Yan Liu wrote:
> Reviewed-by: Chunyan Liu <cyliu(a)suse.com>
Thanks for taking a look! I'm going to push this series since it just splits
your previous patch, which I'm happy to ACK after the split :-). It is a nice
cleanup and plugs potential resource leaks, so good stuff for the 1.3.3 release.
Regards,
Jim
>
>>>> On 3/29/2016 at 08:54 AM, in message
> <1459212889-5490-4-git-send-email-jfehlig(a)suse.com>, Jim Fehlig
> <jfehlig(a)suse.com> wrote:
>> Remove disabling domain death events from libxlDomainStart error
>> path. The domain death event is already disabled in libxlDomainCleanup.
>>
>> Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
>> ---
>> src/libxl/libxl_domain.c | 4 ----
>> 1 file changed, 4 deletions(-)
>>
>> diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
>> index 068bfb6..04962a0 100644
>> --- a/src/libxl/libxl_domain.c
>> +++ b/src/libxl/libxl_domain.c
>> @@ -1144,10 +1144,6 @@ libxlDomainStart(libxlDriverPrivatePtr driver,
>> virDomainObjPtr vm,
>>
>> destroy_dom:
>> ret = -1;
>> - if (priv->deathW) {
>> - libxl_evdisable_domain_death(cfg->ctx, priv->deathW);
>> - priv->deathW = NULL;
>> - }
>> libxlDomainDestroyInternal(driver, vm);
>> vm->def->id = -1;
>> virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF,
>> VIR_DOMAIN_SHUTOFF_FAILED);
>
>
8 years, 8 months
[libvirt] [PATCH 0/3] Decrease execution complexity of formating iothread scheduler info
by Peter Krempa
While refactoring the old way to store iothread scheduler info I've added an
algorithm that isn't entirely optimal but allows to store the scheduler info in
a sane way. Unfortunately when you specify an insane number of iothreads the
code takes ages to execute.
To avoid this series being completely useless except for the one corner case
I've opted to finally add support for self expanding bitmaps, which might become
useful in the future. The self-expanding bitmap is then used instead of one of
the loops that was necessary to determine the maximum iothread ID.
Peter Krempa (3):
util: bitmap: Intoduce self-expanding bitmap APIs
conf: decrease iterations complexity when formatting iothreads
conf: Remove now unused virDomainIOThreadIDMap
src/conf/domain_conf.c | 51 ++++++++++----------------
src/conf/domain_conf.h | 3 --
src/libvirt_private.syms | 4 ++-
src/util/virbitmap.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++
src/util/virbitmap.h | 8 +++++
tests/virbitmaptest.c | 51 ++++++++++++++++++++++++++
6 files changed, 173 insertions(+), 37 deletions(-)
--
2.7.3
8 years, 8 months
[libvirt] [PATCH] bhyve: implement domainShutdown
by Roman Bogorodskiy
Bhyve supports ACPI shutdown by issuing SIGTERM signal to the bhyve
process. Add the bhyveDomainShutdown() function and
virBhyveProcessShutdown() helper function that just sends SIGTERM to
VM's bhyve process. If a guest supports ACPI shutdown then process
will be terminated and this event will be noticed by the bhyve monitor
code that will handle setting proper status and clean up VM's resources.
Also, remove a warning in domainDestroy in case if
virProcessKillPainfully() returns 1, meaning that it killed process
using SIGKILL. This behavior should be expected when using 'destroy'.
---
src/bhyve/bhyve_driver.c | 27 +++++++++++++++++++++++++++
src/bhyve/bhyve_process.c | 30 ++++++++++++++++++++++++++----
src/bhyve/bhyve_process.h | 2 ++
3 files changed, 55 insertions(+), 4 deletions(-)
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index 9219890..b9eacb9 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -1018,6 +1018,32 @@ bhyveDomainDestroy(virDomainPtr dom)
}
static int
+bhyveDomainShutdown(virDomainPtr dom)
+{
+ virDomainObjPtr vm;
+ int ret = -1;
+
+ if (!(vm = bhyveDomObjFromDomain(dom)))
+ goto cleanup;
+
+ if (virDomainShutdownEnsureACL(dom->conn, vm->def) < 0)
+ goto cleanup;
+
+ if (!virDomainObjIsActive(vm)) {
+ virReportError(VIR_ERR_OPERATION_INVALID,
+ "%s", _("Domain is not running"));
+ goto cleanup;
+ }
+
+ ret = virBhyveProcessShutdown(vm);
+
+ cleanup:
+ if (vm)
+ virObjectUnlock(vm);
+ return ret;
+}
+
+static int
bhyveDomainOpenConsole(virDomainPtr dom,
const char *dev_name ATTRIBUTE_UNUSED,
virStreamPtr st,
@@ -1507,6 +1533,7 @@ static virHypervisorDriver bhyveHypervisorDriver = {
.domainCreateWithFlags = bhyveDomainCreateWithFlags, /* 1.2.3 */
.domainCreateXML = bhyveDomainCreateXML, /* 1.2.4 */
.domainDestroy = bhyveDomainDestroy, /* 1.2.2 */
+ .domainShutdown = bhyveDomainShutdown, /* 1.3.3 */
.domainLookupByUUID = bhyveDomainLookupByUUID, /* 1.2.2 */
.domainLookupByName = bhyveDomainLookupByName, /* 1.2.2 */
.domainLookupByID = bhyveDomainLookupByID, /* 1.2.3 */
diff --git a/src/bhyve/bhyve_process.c b/src/bhyve/bhyve_process.c
index 14588a9..fba3896 100644
--- a/src/bhyve/bhyve_process.c
+++ b/src/bhyve/bhyve_process.c
@@ -282,10 +282,9 @@ virBhyveProcessStop(bhyveConnPtr driver,
bhyveMonitorClose(priv->mon);
/* First, try to kill 'bhyve' process */
- if (virProcessKillPainfully(vm->pid, true) != 0)
- VIR_WARN("Failed to gracefully stop bhyve VM '%s' (pid: %d)",
- vm->def->name,
- (int)vm->pid);
+ if (virProcessKillPainfully(vm->pid, true) == -1)
+ VIR_WARN("Failed to kill bhyve process for VM '%s': %s",
+ vm->def->name, virGetLastErrorMessage());
/* Cleanup network interfaces */
bhyveNetCleanup(vm);
@@ -317,6 +316,29 @@ virBhyveProcessStop(bhyveConnPtr driver,
}
int
+virBhyveProcessShutdown(virDomainObjPtr vm)
+{
+ if (vm->pid <= 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Invalid PID %d for VM"),
+ (int)vm->pid);
+ return -1;
+ }
+
+ /* Bhyve tries to perform ACPI shutdown when it receives
+ * SIGTERM signal. So we just issue SIGTERM here and rely
+ * on the bhyve monitor to clean things up if process disappears.
+ */
+ if (virProcessKill(vm->pid, SIGTERM) != 0) {
+ VIR_WARN("Failed to terminate bhyve process for VM '%s': %s",
+ vm->def->name, virGetLastErrorMessage());
+ return -1;
+ }
+
+ return 0;
+}
+
+int
virBhyveGetDomainTotalCpuStats(virDomainObjPtr vm,
unsigned long long *cpustats)
{
diff --git a/src/bhyve/bhyve_process.h b/src/bhyve/bhyve_process.h
index cfa80af..ebabe17 100644
--- a/src/bhyve/bhyve_process.h
+++ b/src/bhyve/bhyve_process.h
@@ -34,6 +34,8 @@ int virBhyveProcessStop(bhyveConnPtr driver,
virDomainObjPtr vm,
virDomainShutoffReason reason);
+int virBhyveProcessShutdown(virDomainObjPtr vm);
+
int virBhyveGetDomainTotalCpuStats(virDomainObjPtr vm,
unsigned long long *cpustats);
--
2.7.4
8 years, 8 months
[libvirt] [PATCH] perf: fix build on non-Linux
by Roman Bogorodskiy
* Sync stubbed functions with prototypes
* Add missing ATTRIBUTE_UNUSED where needed
Pushing under the build breaker rule.
---
src/util/virperf.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/util/virperf.c b/src/util/virperf.c
index 42eee85..9dc4e25 100644
--- a/src/util/virperf.c
+++ b/src/util/virperf.c
@@ -262,6 +262,7 @@ virPerfReadEvent(virPerfPtr perf,
#else
int
virPerfEventEnable(virPerfPtr perf ATTRIBUTE_UNUSED,
+ virPerfEventType type ATTRIBUTE_UNUSED,
pid_t pid ATTRIBUTE_UNUSED)
{
virReportSystemError(ENXIO, "%s",
@@ -271,7 +272,7 @@ virPerfEventEnable(virPerfPtr perf ATTRIBUTE_UNUSED,
int
virPerfEventDisable(virPerfPtr perf ATTRIBUTE_UNUSED,
- int event ATTRIBUTE_UNUSED)
+ virPerfEventType type ATTRIBUTE_UNUSED)
{
virReportSystemError(ENXIO, "%s",
_("Perf not supported on this platform"));
@@ -279,15 +280,15 @@ virPerfEventDisable(virPerfPtr perf ATTRIBUTE_UNUSED,
}
bool
-virPerfEventIsEnabled(virPerfPtr perf,
- virPerfEventType type)
+virPerfEventIsEnabled(virPerfPtr perf ATTRIBUTE_UNUSED,
+ virPerfEventType type ATTRIBUTE_UNUSED)
{
return false;
}
int
-virPerfGetEventFd(virPerfPtr perf,
- virPerfEventType type)
+virPerfGetEventFd(virPerfPtr perf ATTRIBUTE_UNUSED,
+ virPerfEventType type ATTRIBUTE_UNUSED)
{
virReportSystemError(ENXIO, "%s",
_("Perf not supported on this platform"));
@@ -295,9 +296,9 @@ virPerfGetEventFd(virPerfPtr perf,
}
int
-virPerfReadEvent(virPerfPtr perf,
- virPerfEventType type
- uint64_t *value)
+virPerfReadEvent(virPerfPtr perf ATTRIBUTE_UNUSED,
+ virPerfEventType type ATTRIBUTE_UNUSED,
+ uint64_t *value ATTRIBUTE_UNUSED)
{
virReportSystemError(ENXIO, "%s",
_("Perf not supported on this platform"));
--
2.7.4
8 years, 8 months
[libvirt] [PATCH 0/3] Add a domain masterKey secret for qemu
by John Ferlan
Differences to RFC:
http://www.redhat.com/archives/libvir-list/2016-March/msg00966.html
(many, but highlights are):
* Patch2 is Patch1 and I figured out the 'qom-list-types' magic in order
to fill in the .replies file
* Use of qemuDomainObjPrivate rather than passing 'masterKey'
* The masterKey is not stored in XML output nor is it stored as a
base64 value
* The masterKey is created during qemuProcessPrepareHost right after
the libDir is created. It is only created if the capability exists.
* The masterKey is removed during qemuProcessStop. There is no call
to qemuDomainMasterKeyRemove from qemuDomainObjPrivateFree since
the assumption is the *Stop code will handle things.
* Created a qemuDomainMasterKeyReadFile to handle reading the master.key
file during qemuProcessReconnect rather than the prior code which would
have taken the masterKey from the XML file in base64 format.
* The MasterKeyCreate and MasterKeyRemove incorporate the file manipulation
as well. The *Create code will save the base64 encoded secret. The callers
need only call those API's.
* The masterKey is generated using gnutls_rnd if that's available
(following examples w/ HAVE_GNUTLS_CRYPTO_H); otherwise, the fallback
position is the virRandomBits.
* Moved alias code to qemu_alias.c instead of qemu_domain.c.
Notes on comments where I didn't change things:
* Since qemuBuildCommandLine doesn't get the qemuDomainObjPrivate, I
kept the qemuBuildHasMasterKey checking the capability bit only.
Other *CommandLine callers would use the same decision point. If
the key was available, then "assume" it's already present on the
command line since there's no failure path from building the
master key command line.
* I kept the write "0" to the key file just before deletion. I wasn't
sure with file caches being as they can be if there could ever be that
100% guarantee that what was unlink()'d really "went away" completely.
Something I noted and wasn't "clear" how to resolve, so I followed existing
practices of not checking if something exists:
* The recent changes to have a qemuProcessCreatePretendCmd which will
allow libDir and channelTargetDir creation using "/tmp/", but not
actually creating the directory inhibit this code from being able to
check if the path to the masterKey exists before sending it to qemu.
Now if the 'flags' was passed to qemuBuildCommandLine and the
VIR_QEMU_PROCESS_START_PRETEND could be checked while building the
MasterKey command line, then I could have the check in. Otherwise,
I just have to assume everything's worked "right" up to this point.
A secondary note on that... Why "/tmp/" - shouldn't have been "tmp/"?
John Ferlan (3):
qemu: Add capability bit for qemu secret object
qemu: Create domain master key
qemu: Introduce qemuBuildMasterKeyCommandLine
src/qemu/qemu_alias.c | 17 ++
src/qemu/qemu_alias.h | 3 +
src/qemu/qemu_capabilities.c | 2 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 68 ++++++
src/qemu/qemu_domain.c | 269 +++++++++++++++++++++
src/qemu/qemu_domain.h | 13 +
src/qemu/qemu_process.c | 11 +
tests/qemucapabilitiesdata/caps_2.6.0-1.caps | 1 +
tests/qemucapabilitiesdata/caps_2.6.0-1.replies | 3 +
.../qemuxml2argvdata/qemuxml2argv-master-key.args | 23 ++
tests/qemuxml2argvdata/qemuxml2argv-master-key.xml | 30 +++
tests/qemuxml2argvtest.c | 2 +
13 files changed, 443 insertions(+)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-master-key.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-master-key.xml
--
2.5.0
8 years, 8 months