Compare commits
77 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0831c388ec | |||
| b59373e03c | |||
| d617f580c5 | |||
| 7415198273 | |||
| 0ceadbef50 | |||
| 82f2674fae | |||
| 91063332d7 | |||
| 503330ba5d | |||
| 0a64085f47 | |||
| 1073e2447a | |||
| 5b1a906ace | |||
| aff97e0146 | |||
| a4b41a378b | |||
| 3ec523d168 | |||
| 622cf0d642 | |||
| a540751e83 | |||
| 11b596669a | |||
| fefbae879b | |||
| 695b281409 | |||
| 9f9eae34c1 | |||
| ae37ed3500 | |||
| f7f509999b | |||
| 419bcc4b2f | |||
| 7b59d4f7eb | |||
| 03326e9c04 | |||
| f40b464d1e | |||
| 810ca6c207 | |||
| 8df3aef6aa | |||
| 0223d5a656 | |||
| aad810a204 | |||
| 1b8b7567b1 | |||
| 442040caac | |||
| 65efaafca2 | |||
| e87c8ab0c7 | |||
| be6bda45b4 | |||
| 8c9e40d383 | |||
| 0f6f9b973a | |||
| 3db6039b2b | |||
| 4051217c8b | |||
| c5c28baba1 | |||
| 43618df1d4 | |||
| a2951dccb5 | |||
| b884323c03 | |||
| adeaf839fd | |||
| 40d99010e1 | |||
| 11755d8663 | |||
| 2daa92daf9 | |||
| db2858c661 | |||
| 53adb9aaba | |||
| 168df8b606 | |||
| f9085f2538 | |||
| b159bbdc98 | |||
| a5af3cf105 | |||
| 27ca069db7 | |||
| 000a3274d2 | |||
| 19c7799c31 | |||
| 198ff818c6 | |||
| e80c83ad06 | |||
| 660e0112c6 | |||
| 45c1cabef6 | |||
| 56be2c5e38 | |||
| 4aa9c4f1a3 | |||
| 7be420ad22 | |||
| 40b00623a4 | |||
| ce09ec66c7 | |||
| 97d7c80e2e | |||
| b856ae03bf | |||
| 803b3b891a | |||
| 350081d1a9 | |||
| 1b71b68bb9 | |||
| 4084288dd5 | |||
| d1cd1b7ceb | |||
| 5ed69704b9 | |||
| be6e136cb1 | |||
| d3109abfa4 | |||
| f5ff4a2393 | |||
| 8cc50838dc |
@@ -0,0 +1,206 @@
|
||||
From: Prerna Saxena <prerna@linux.vnet.ibm.com>
|
||||
Date: Tue, 4 Nov 2014 22:51:26 +0530
|
||||
Subject: [PATCH] Cpu: Add support for Power LE Architecture.
|
||||
|
||||
This adds support for PowerPC Little Endian architecture.,
|
||||
and allows libvirt to spawn VMs based on 'ppc64le' architecture.
|
||||
|
||||
Signed-off-by: Pradipta Kr. Banerjee <bpradip@in.ibm.com>
|
||||
Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
|
||||
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
||||
(cherry picked from commit da636d83dc6b1d070a705786b4daef8644eaca13)
|
||||
---
|
||||
src/conf/domain_conf.c | 2 +-
|
||||
src/cpu/cpu_powerpc.c | 2 +-
|
||||
src/qemu/qemu_capabilities.c | 6 +++---
|
||||
src/qemu/qemu_command.c | 22 +++++++++++-----------
|
||||
src/qemu/qemu_domain.c | 1 +
|
||||
src/util/virarch.h | 3 +++
|
||||
6 files changed, 20 insertions(+), 16 deletions(-)
|
||||
|
||||
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
|
||||
index cfdf66c..8aca289 100644
|
||||
--- a/src/conf/domain_conf.c
|
||||
+++ b/src/conf/domain_conf.c
|
||||
@@ -9867,7 +9867,7 @@ virDomainVideoDefaultType(const virDomainDef *def)
|
||||
(STREQ(def->os.type, "xen") ||
|
||||
STREQ(def->os.type, "linux")))
|
||||
return VIR_DOMAIN_VIDEO_TYPE_XEN;
|
||||
- else if (def->os.arch == VIR_ARCH_PPC64)
|
||||
+ else if ARCH_IS_PPC64(def->os.arch)
|
||||
return VIR_DOMAIN_VIDEO_TYPE_VGA;
|
||||
else
|
||||
return VIR_DOMAIN_VIDEO_TYPE_CIRRUS;
|
||||
diff --git a/src/cpu/cpu_powerpc.c b/src/cpu/cpu_powerpc.c
|
||||
index 67cb9ff..d591c18 100644
|
||||
--- a/src/cpu/cpu_powerpc.c
|
||||
+++ b/src/cpu/cpu_powerpc.c
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
VIR_LOG_INIT("cpu.cpu_powerpc");
|
||||
|
||||
-static const virArch archs[] = { VIR_ARCH_PPC64 };
|
||||
+static const virArch archs[] = { VIR_ARCH_PPC64, VIR_ARCH_PPC64LE };
|
||||
|
||||
struct ppc_vendor {
|
||||
char *name;
|
||||
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
|
||||
index be4d01f..34d753c 100644
|
||||
--- a/src/qemu/qemu_capabilities.c
|
||||
+++ b/src/qemu/qemu_capabilities.c
|
||||
@@ -632,7 +632,7 @@ virQEMUCapsProbeCPUModels(virQEMUCapsPtr qemuCaps, uid_t runUid, gid_t runGid)
|
||||
if (qemuCaps->arch == VIR_ARCH_I686 ||
|
||||
qemuCaps->arch == VIR_ARCH_X86_64) {
|
||||
parse = virQEMUCapsParseX86Models;
|
||||
- } else if (qemuCaps->arch == VIR_ARCH_PPC64) {
|
||||
+ } else if ARCH_IS_PPC64(qemuCaps->arch) {
|
||||
parse = virQEMUCapsParsePPCModels;
|
||||
} else {
|
||||
VIR_DEBUG("don't know how to parse %s CPU models",
|
||||
@@ -2018,7 +2018,7 @@ bool virQEMUCapsHasPCIMultiBus(virQEMUCapsPtr qemuCaps,
|
||||
return true;
|
||||
|
||||
if (def->os.arch == VIR_ARCH_PPC ||
|
||||
- def->os.arch == VIR_ARCH_PPC64) {
|
||||
+ ARCH_IS_PPC64(def->os.arch)) {
|
||||
/*
|
||||
* Usage of pci.0 naming:
|
||||
*
|
||||
@@ -3600,7 +3600,7 @@ virQEMUCapsSupportsChardev(virDomainDefPtr def,
|
||||
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE))
|
||||
return false;
|
||||
|
||||
- if ((def->os.arch == VIR_ARCH_PPC) || (def->os.arch == VIR_ARCH_PPC64)) {
|
||||
+ if ((def->os.arch == VIR_ARCH_PPC) || ARCH_IS_PPC64(def->os.arch)) {
|
||||
/* only pseries need -device spapr-vty with -chardev */
|
||||
return (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
|
||||
chr->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO);
|
||||
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
|
||||
index aeb4eec..c5c48bf 100644
|
||||
--- a/src/qemu/qemu_command.c
|
||||
+++ b/src/qemu/qemu_command.c
|
||||
@@ -713,7 +713,7 @@ qemuSetSCSIControllerModel(virDomainDefPtr def,
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
- if ((def->os.arch == VIR_ARCH_PPC64) &&
|
||||
+ if (ARCH_IS_PPC64(def->os.arch) &&
|
||||
STRPREFIX(def->os.machine, "pseries")) {
|
||||
*model = VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI;
|
||||
} else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_LSI)) {
|
||||
@@ -1260,7 +1260,7 @@ int qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def,
|
||||
|
||||
for (i = 0; i < def->nserials; i++) {
|
||||
if (def->serials[i]->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
|
||||
- (def->os.arch == VIR_ARCH_PPC64) &&
|
||||
+ ARCH_IS_PPC64(def->os.arch) &&
|
||||
STRPREFIX(def->os.machine, "pseries"))
|
||||
def->serials[i]->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO;
|
||||
if (qemuAssignSpaprVIOAddress(def, &def->serials[i]->info,
|
||||
@@ -1269,7 +1269,7 @@ int qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def,
|
||||
}
|
||||
|
||||
if (def->nvram) {
|
||||
- if (def->os.arch == VIR_ARCH_PPC64 &&
|
||||
+ if (ARCH_IS_PPC64(def->os.arch) &&
|
||||
STRPREFIX(def->os.machine, "pseries"))
|
||||
def->nvram->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO;
|
||||
if (qemuAssignSpaprVIOAddress(def, &def->nvram->info,
|
||||
@@ -4191,7 +4191,7 @@ qemuBuildUSBControllerDevStr(virDomainDefPtr domainDef,
|
||||
model = def->model;
|
||||
|
||||
if (model == -1) {
|
||||
- if (domainDef->os.arch == VIR_ARCH_PPC64)
|
||||
+ if ARCH_IS_PPC64(domainDef->os.arch)
|
||||
model = VIR_DOMAIN_CONTROLLER_MODEL_USB_PCI_OHCI;
|
||||
else
|
||||
model = VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX3_UHCI;
|
||||
@@ -8445,7 +8445,7 @@ qemuBuildCommandLine(virConnectPtr conn,
|
||||
!qemuDomainMachineIsQ35(def) &&
|
||||
(!virQEMUCapsGet(qemuCaps, QEMU_CAPS_PIIX3_USB_UHCI) ||
|
||||
(!virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCI_OHCI) &&
|
||||
- def->os.arch == VIR_ARCH_PPC64))) {
|
||||
+ ARCH_IS_PPC64(def->os.arch)))) {
|
||||
if (usblegacy) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("Multiple legacy USB controllers are "
|
||||
@@ -9643,7 +9643,7 @@ qemuBuildCommandLine(virConnectPtr conn,
|
||||
}
|
||||
|
||||
if (def->nvram) {
|
||||
- if (def->os.arch == VIR_ARCH_PPC64 &&
|
||||
+ if (ARCH_IS_PPC64(def->os.arch) &&
|
||||
STRPREFIX(def->os.machine, "pseries")) {
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_NVRAM)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
@@ -9761,7 +9761,7 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
|
||||
{
|
||||
virBuffer cmd = VIR_BUFFER_INITIALIZER;
|
||||
|
||||
- if ((arch == VIR_ARCH_PPC64) && STRPREFIX(machine, "pseries")) {
|
||||
+ if (ARCH_IS_PPC64(arch) && STRPREFIX(machine, "pseries")) {
|
||||
if (serial->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
|
||||
serial->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO) {
|
||||
virBufferAsprintf(&cmd, "spapr-vty,chardev=char%s",
|
||||
@@ -10183,7 +10183,7 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
|
||||
if (VIR_ALLOC(def->src) < 0)
|
||||
goto error;
|
||||
|
||||
- if (((dom->os.arch == VIR_ARCH_PPC64) &&
|
||||
+ if ((ARCH_IS_PPC64(dom->os.arch) &&
|
||||
dom->os.machine && STRPREFIX(dom->os.machine, "pseries")))
|
||||
def->bus = VIR_DOMAIN_DISK_BUS_SCSI;
|
||||
else
|
||||
@@ -10276,7 +10276,7 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
|
||||
} else if (STREQ(keywords[i], "if")) {
|
||||
if (STREQ(values[i], "ide")) {
|
||||
def->bus = VIR_DOMAIN_DISK_BUS_IDE;
|
||||
- if (((dom->os.arch == VIR_ARCH_PPC64) &&
|
||||
+ if ((ARCH_IS_PPC64(dom->os.arch) &&
|
||||
dom->os.machine && STRPREFIX(dom->os.machine, "pseries"))) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("pseries systems do not support ide devices '%s'"), val);
|
||||
@@ -11521,7 +11521,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
|
||||
}
|
||||
if (STREQ(arg, "-cdrom")) {
|
||||
disk->device = VIR_DOMAIN_DISK_DEVICE_CDROM;
|
||||
- if (((def->os.arch == VIR_ARCH_PPC64) &&
|
||||
+ if ((ARCH_IS_PPC64(def->os.arch) &&
|
||||
def->os.machine && STRPREFIX(def->os.machine, "pseries")))
|
||||
disk->bus = VIR_DOMAIN_DISK_BUS_SCSI;
|
||||
if (VIR_STRDUP(disk->dst, "hdc") < 0)
|
||||
@@ -11537,7 +11537,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
|
||||
disk->bus = VIR_DOMAIN_DISK_BUS_IDE;
|
||||
else
|
||||
disk->bus = VIR_DOMAIN_DISK_BUS_SCSI;
|
||||
- if (((def->os.arch == VIR_ARCH_PPC64) &&
|
||||
+ if ((ARCH_IS_PPC64(def->os.arch) &&
|
||||
def->os.machine && STRPREFIX(def->os.machine, "pseries")))
|
||||
disk->bus = VIR_DOMAIN_DISK_BUS_SCSI;
|
||||
}
|
||||
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
|
||||
index bec7cf2..48e8acf 100644
|
||||
--- a/src/qemu/qemu_domain.c
|
||||
+++ b/src/qemu/qemu_domain.c
|
||||
@@ -980,6 +980,7 @@ qemuDomainDefPostParse(virDomainDefPtr def,
|
||||
break;
|
||||
|
||||
case VIR_ARCH_PPC64:
|
||||
+ case VIR_ARCH_PPC64LE:
|
||||
addPCIRoot = true;
|
||||
addDefaultUSBKBD = true;
|
||||
addDefaultUSBMouse = true;
|
||||
diff --git a/src/util/virarch.h b/src/util/virarch.h
|
||||
index d395e58..3206ce2 100644
|
||||
--- a/src/util/virarch.h
|
||||
+++ b/src/util/virarch.h
|
||||
@@ -79,6 +79,9 @@ typedef enum {
|
||||
(arch) == VIR_ARCH_PPC64LE ||\
|
||||
(arch) == VIR_ARCH_PPCEMB)
|
||||
|
||||
+# define ARCH_IS_PPC64(arch) ((arch) == VIR_ARCH_PPC64 ||\
|
||||
+ (arch) == VIR_ARCH_PPC64LE)
|
||||
+
|
||||
# define ARCH_IS_ARM(arch) ((arch) == VIR_ARCH_ARMV6L ||\
|
||||
(arch) == VIR_ARCH_ARMV7L ||\
|
||||
(arch) == VIR_ARCH_ARMV7B ||\
|
||||
@@ -1,27 +0,0 @@
|
||||
From 37865f1dead1fac2ee34af48f96d19d686296e04 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 13 Sep 2012 14:37:22 +0100
|
||||
Subject: [PATCH] Use 'qemu-system-i386' as binary instead of 'qemu'.
|
||||
|
||||
---
|
||||
src/qemu/qemu_capabilities.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
|
||||
index af3b0b2..179b3d2 100644
|
||||
--- a/src/qemu/qemu_capabilities.c
|
||||
+++ b/src/qemu/qemu_capabilities.c
|
||||
@@ -244,8 +244,8 @@ static const struct qemu_feature_flags const arch_info_x86_64_flags [] = {
|
||||
|
||||
/* The archicture tables for supported QEMU archs */
|
||||
static const struct qemu_arch_info const arch_info_hvm[] = {
|
||||
- { "i686", 32, NULL, "qemu",
|
||||
- "qemu-system-x86_64", arch_info_i686_flags, 4 },
|
||||
+ { "i686", 32, NULL, "qemu-system-i386",
|
||||
+ NULL, arch_info_i686_flags, 4 },
|
||||
{ "x86_64", 64, NULL, "qemu-system-x86_64",
|
||||
NULL, arch_info_x86_64_flags, 2 },
|
||||
{ "arm", 32, NULL, "qemu-system-arm", NULL, NULL, 0 },
|
||||
--
|
||||
1.7.11.4
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
From: Prerna Saxena <prerna@linux.vnet.ibm.com>
|
||||
Date: Tue, 4 Nov 2014 22:52:44 +0530
|
||||
Subject: [PATCH] PowerPC : Add support for launching VM in 'compat' mode.
|
||||
|
||||
PowerISA allows processors to run VMs in binary compatibility ("compat")
|
||||
mode supporting an older version of ISA. QEMU has recently added support to
|
||||
explicitly denote a VM running in compatibility mode through commit 6d9412ea
|
||||
& 8dfa3a5e85. Now, a "compat" mode VM can be run by invoking this qemu
|
||||
commandline on a POWER8 host: -cpu host,compat=power7.
|
||||
|
||||
This patch allows libvirt to exploit cpu mode 'host-model' to describe this
|
||||
new mode for PowerKVM guests. For example, when a user wants to request a
|
||||
power7 vm to run in compatibility mode on a Power8 host, this can be
|
||||
described in XML as follows :
|
||||
|
||||
<cpu mode='host-model'>
|
||||
<model>power7</model>
|
||||
</cpu>
|
||||
|
||||
Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
|
||||
Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
|
||||
Signed-off-by: Pradipta Kr. Banerjee <bpradip@in.ibm.com>
|
||||
Acked-by: Michal Privoznik <mprivozn@redhat.com>
|
||||
(cherry picked from commit addce06c9221f948072cd222b56ea9c3f70ec066)
|
||||
---
|
||||
src/conf/cpu_conf.c | 1 +
|
||||
src/cpu/cpu_powerpc.c | 11 ++---------
|
||||
src/qemu/qemu_command.c | 10 +++++++++-
|
||||
3 files changed, 12 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
|
||||
index c09c352..74f0b16 100644
|
||||
--- a/src/conf/cpu_conf.c
|
||||
+++ b/src/conf/cpu_conf.c
|
||||
@@ -624,6 +624,7 @@ virCPUDefFormatBuf(virBufferPtr buf,
|
||||
return 0;
|
||||
|
||||
formatModel = (def->mode == VIR_CPU_MODE_CUSTOM ||
|
||||
+ def->mode == VIR_CPU_MODE_HOST_MODEL ||
|
||||
(flags & VIR_DOMAIN_XML_UPDATE_CPU));
|
||||
formatFallback = (def->type == VIR_CPU_TYPE_GUEST &&
|
||||
(def->mode == VIR_CPU_MODE_HOST_MODEL ||
|
||||
diff --git a/src/cpu/cpu_powerpc.c b/src/cpu/cpu_powerpc.c
|
||||
index d591c18..4ea1835 100644
|
||||
--- a/src/cpu/cpu_powerpc.c
|
||||
+++ b/src/cpu/cpu_powerpc.c
|
||||
@@ -562,8 +562,8 @@ ppcUpdate(virCPUDefPtr guest,
|
||||
static virCPUDefPtr
|
||||
ppcBaseline(virCPUDefPtr *cpus,
|
||||
unsigned int ncpus,
|
||||
- const char **models,
|
||||
- unsigned int nmodels,
|
||||
+ const char **models ATTRIBUTE_UNUSED,
|
||||
+ unsigned int nmodels ATTRIBUTE_UNUSED,
|
||||
unsigned int flags)
|
||||
{
|
||||
struct ppc_map *map = NULL;
|
||||
@@ -583,13 +583,6 @@ ppcBaseline(virCPUDefPtr *cpus,
|
||||
goto error;
|
||||
}
|
||||
|
||||
- if (!cpuModelIsAllowed(model->name, models, nmodels)) {
|
||||
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
- _("CPU model %s is not supported by hypervisor"),
|
||||
- model->name);
|
||||
- goto error;
|
||||
- }
|
||||
-
|
||||
for (i = 0; i < ncpus; i++) {
|
||||
const struct ppc_vendor *vnd;
|
||||
|
||||
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
|
||||
index c5c48bf..423692e 100644
|
||||
--- a/src/qemu/qemu_command.c
|
||||
+++ b/src/qemu/qemu_command.c
|
||||
@@ -6217,7 +6217,9 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
|
||||
*hasHwVirt = hasSVM > 0 ? true : false;
|
||||
}
|
||||
|
||||
- if (cpu->mode == VIR_CPU_MODE_HOST_PASSTHROUGH) {
|
||||
+ if ((cpu->mode == VIR_CPU_MODE_HOST_PASSTHROUGH) ||
|
||||
+ ((cpu->mode == VIR_CPU_MODE_HOST_MODEL) &&
|
||||
+ ARCH_IS_PPC64(def->os.arch))) {
|
||||
const char *mode = virCPUModeTypeToString(cpu->mode);
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CPU_HOST)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
@@ -6232,6 +6234,12 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
|
||||
goto cleanup;
|
||||
}
|
||||
virBufferAddLit(buf, "host");
|
||||
+
|
||||
+ if (ARCH_IS_PPC64(def->os.arch) &&
|
||||
+ cpu->mode == VIR_CPU_MODE_HOST_MODEL) {
|
||||
+ virBufferAsprintf(buf, ",compat=%s", def->cpu->model);
|
||||
+ }
|
||||
+
|
||||
} else {
|
||||
if (VIR_ALLOC(guest) < 0)
|
||||
goto cleanup;
|
||||
@@ -0,0 +1,92 @@
|
||||
From: Prerna Saxena <prerna@linux.vnet.ibm.com>
|
||||
Date: Tue, 4 Nov 2014 22:58:33 +0530
|
||||
Subject: [PATCH] PowerPC:Improve PVR handling to fall back to cpu generation.
|
||||
|
||||
IBM Power processors differ uniquely across generations (such as power6,
|
||||
power7, power8). Each generation signifies a new PowerISA version
|
||||
that exhibits features unique to that generation.
|
||||
The higher 16 bits of PVR for IBM Power processors encode the CPU
|
||||
generation, while the CPU chip (sub)version is encoded in lower 16 bits.
|
||||
|
||||
For all practical purposes of launching a VM, we care about the
|
||||
generation which the vCPU will belong to, and not specifically the chip
|
||||
version. This patch updates the libvirt PVR check to reflect this
|
||||
relationship. It allows libvirt to select the right CPU generation
|
||||
in case the exact match for a a specific CPU is not found.
|
||||
Hence, there will no longer be a need to add each PowerPC CPU model to
|
||||
cpu_map.xml; just adding entry for the matching ISA generation will
|
||||
suffice.
|
||||
|
||||
It also contains changes to cpu_map.xml since processor generations
|
||||
as understood by QEMU compat mode go as "power6", "power7" or "power8"
|
||||
[Reference : QEMU commit 8dfa3a5e85 ]
|
||||
|
||||
Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
|
||||
Signed-off-by: Pradipta Kr. Banerjee <bpradip@in.ibm.com>
|
||||
Signed-off-by: Anton Blanchard <anton@samba.org>
|
||||
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
||||
(cherry picked from commit 1e911742287d964055f33ab76d53e673a9b4477f)
|
||||
---
|
||||
src/cpu/cpu_map.xml | 30 ++++++++++++++++++++++++++++++
|
||||
src/cpu/cpu_powerpc.c | 8 ++++++++
|
||||
2 files changed, 38 insertions(+)
|
||||
|
||||
diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
|
||||
index d181cd5..4ec49ca 100644
|
||||
--- a/src/cpu/cpu_map.xml
|
||||
+++ b/src/cpu/cpu_map.xml
|
||||
@@ -637,5 +637,35 @@
|
||||
<pvr value='0x004b0100'/>
|
||||
</model>
|
||||
|
||||
+ <model name='power6'>
|
||||
+ <vendor name='IBM'/>
|
||||
+ <compat isa='2.05'/>
|
||||
+ <pvr value='0x003e0000'/>
|
||||
+ </model>
|
||||
+
|
||||
+ <model name='power7'>
|
||||
+ <vendor name='IBM'/>
|
||||
+ <compat isa='2.06'/>
|
||||
+ <pvr value='0x003f0000'/>
|
||||
+ </model>
|
||||
+
|
||||
+ <model name='power7+'>
|
||||
+ <vendor name='IBM'/>
|
||||
+ <compat isa='2.06B'/>
|
||||
+ <pvr value='0x004a0000'/>
|
||||
+ </model>
|
||||
+
|
||||
+ <model name='power8e'>
|
||||
+ <vendor name='IBM'/>
|
||||
+ <compat isa='2.07'/>
|
||||
+ <pvr value='0x004b0000'/>
|
||||
+ </model>
|
||||
+
|
||||
+ <model name='power8'>
|
||||
+ <vendor name='IBM'/>
|
||||
+ <compat isa='2.07'/>
|
||||
+ <pvr value='0x004d0000'/>
|
||||
+ </model>
|
||||
+
|
||||
</arch>
|
||||
</cpus>
|
||||
diff --git a/src/cpu/cpu_powerpc.c b/src/cpu/cpu_powerpc.c
|
||||
index 4ea1835..531868c 100644
|
||||
--- a/src/cpu/cpu_powerpc.c
|
||||
+++ b/src/cpu/cpu_powerpc.c
|
||||
@@ -99,6 +99,14 @@ ppcModelFindPVR(const struct ppc_map *map,
|
||||
model = model->next;
|
||||
}
|
||||
|
||||
+ /* PowerPC Processor Version Register is interpreted as follows :
|
||||
+ * Higher order 16 bits : Power ISA generation.
|
||||
+ * Lower order 16 bits : CPU chip version number.
|
||||
+ * If the exact CPU isnt found, return the nearest matching CPU generation
|
||||
+ */
|
||||
+ if (pvr & 0x0000FFFFul)
|
||||
+ return ppcModelFindPVR(map, (pvr & 0xFFFF0000ul));
|
||||
+
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
From: Prerna Saxena <prerna@linux.vnet.ibm.com>
|
||||
Date: Tue, 4 Nov 2014 23:00:36 +0530
|
||||
Subject: [PATCH] docs: Add documentation for compat mode.
|
||||
|
||||
Add documentation to explain how compat-mode can be invoked with libvirt
|
||||
running on PowerPC architecture.
|
||||
It also mentions that this change is available libvirt 1.2.11 onwards.
|
||||
|
||||
Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
|
||||
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
||||
(cherry picked from commit 9265fd19b68d787e478f5e490524da794965a5f1)
|
||||
---
|
||||
docs/formatdomain.html.in | 15 ++++++++++++++-
|
||||
1 file changed, 14 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
|
||||
index 12172a4..6c64230 100644
|
||||
--- a/docs/formatdomain.html.in
|
||||
+++ b/docs/formatdomain.html.in
|
||||
@@ -1047,7 +1047,20 @@
|
||||
(such as CPUID level) that don't work. Until these issues are fixed,
|
||||
it's a good idea to avoid using <code>host-model</code> and use
|
||||
<code>custom</code> mode with just the CPU model from host
|
||||
- capabilities XML.</dd>
|
||||
+ capabilities XML.
|
||||
+ <span class="since">(Since 1.2.11)</span>. PowerISA allows
|
||||
+ processors to run VMs in binary compatibility mode supporting an
|
||||
+ older version of ISA. Libvirt on PowerPC architecture uses the
|
||||
+ <code>host-model</code> to signify a guest mode CPU running in
|
||||
+ binary compatibility mode. Example:
|
||||
+ When a user needs a power7 VM to run in compatibility mode
|
||||
+ on a Power8 host, this can be described in XML as follows :
|
||||
+<pre>
|
||||
+ <cpu mode='host-model'>
|
||||
+ <model>power7</model>
|
||||
+ </cpu>
|
||||
+ ...</pre>
|
||||
+ </dd>
|
||||
<dt><code>host-passthrough</code></dt>
|
||||
<dd>With this mode, the CPU visible to the guest should be exactly
|
||||
the same as the host CPU even in the aspects that libvirt does not
|
||||
@@ -0,0 +1,71 @@
|
||||
From: Prerna Saxena <prerna@linux.vnet.ibm.com>
|
||||
Date: Tue, 4 Nov 2014 23:02:15 +0530
|
||||
Subject: [PATCH] Test: Add a testcase for PowerPC compat mode cpu
|
||||
specification.
|
||||
|
||||
This introduces a testcase for PowerPC compat mode cpu specification.
|
||||
|
||||
Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
|
||||
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
||||
(cherry picked from commit 12c381114ce362e49cadb730b5faabbc150a8878)
|
||||
---
|
||||
.../qemuxml2argv-pseries-cpu-compat.args | 8 ++++++++
|
||||
.../qemuxml2argv-pseries-cpu-compat.xml | 20 ++++++++++++++++++++
|
||||
tests/qemuxml2argvtest.c | 2 ++
|
||||
3 files changed, 30 insertions(+)
|
||||
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat.args
|
||||
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat.xml
|
||||
|
||||
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat.args
|
||||
new file mode 100644
|
||||
index 0000000..64df406
|
||||
--- /dev/null
|
||||
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat.args
|
||||
@@ -0,0 +1,8 @@
|
||||
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \
|
||||
+QEMU_AUDIO_DRV=none /usr/bin/qemu-system-ppc64 -S -M pseries \
|
||||
+-cpu host,compat=power7 \
|
||||
+-m 214 -smp 4 -nographic -nodefconfig -nodefaults \
|
||||
+-chardev socket,id=charmonitor,path=/tmp/test-monitor,server,nowait \
|
||||
+-mon chardev=charmonitor,id=monitor,mode=readline -no-acpi -boot c -usb \
|
||||
+-chardev pty,id=charserial0 \
|
||||
+-device spapr-vty,chardev=charserial0,reg=0x30000000
|
||||
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat.xml
|
||||
new file mode 100644
|
||||
index 0000000..e34a8ad
|
||||
--- /dev/null
|
||||
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat.xml
|
||||
@@ -0,0 +1,20 @@
|
||||
+<domain type='kvm'>
|
||||
+ <name>QEMUGuest1</name>
|
||||
+ <memory unit='KiB'>219100</memory>
|
||||
+ <currentMemory unit='KiB'>219100</currentMemory>
|
||||
+ <vcpu placement='static'>4</vcpu>
|
||||
+ <os>
|
||||
+ <type arch='ppc64' machine='pseries'>hvm</type>
|
||||
+ </os>
|
||||
+ <cpu mode='host-model'>
|
||||
+ <model>power7</model>
|
||||
+ </cpu>
|
||||
+ <clock offset='utc'/>
|
||||
+ <devices>
|
||||
+ <emulator>/usr/bin/qemu-system-ppc64</emulator>
|
||||
+ <console type='pty'>
|
||||
+ <address type="spapr-vio"/>
|
||||
+ </console>
|
||||
+ <memballoon model="none"/>
|
||||
+ </devices>
|
||||
+</domain>
|
||||
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
|
||||
index 5539a84..e24d17f 100644
|
||||
--- a/tests/qemuxml2argvtest.c
|
||||
+++ b/tests/qemuxml2argvtest.c
|
||||
@@ -1314,6 +1314,8 @@ mymain(void)
|
||||
QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
|
||||
DO_TEST("pseries-cpu-exact", QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE,
|
||||
QEMU_CAPS_NODEFCONFIG);
|
||||
+ DO_TEST("pseries-cpu-compat", QEMU_CAPS_KVM, QEMU_CAPS_CPU_HOST,
|
||||
+ QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
|
||||
DO_TEST("disk-ide-drive-split",
|
||||
QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
|
||||
QEMU_CAPS_IDE_CD);
|
||||
@@ -0,0 +1,126 @@
|
||||
From: Cole Robinson <crobinso@redhat.com>
|
||||
Date: Tue, 28 Apr 2015 17:38:00 -0400
|
||||
Subject: [PATCH] polkit: Allow password-less access for 'libvirt' group
|
||||
|
||||
Many users, who admin their own machines, want to be able to access
|
||||
system libvirtd via tools like virt-manager without having to enter
|
||||
a root password. Just google 'virt-manager without password' and
|
||||
you'll find many hits. I've read at least 5 blog posts over the years
|
||||
describing slightly different ways of achieving this goal.
|
||||
|
||||
Let's finally add official support for this.
|
||||
|
||||
Install a polkit-1 rules file granting password-less auth for any user
|
||||
in the new 'libvirt' group. Create the group on RPM install
|
||||
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=957300
|
||||
(cherry picked from commit e94979e901517af9fdde358d7b7c92cc055dd50c)
|
||||
---
|
||||
daemon/Makefile.am | 13 +++++++++++++
|
||||
daemon/libvirt.rules | 9 +++++++++
|
||||
libvirt.spec.in | 15 +++++++++++++--
|
||||
3 files changed, 35 insertions(+), 2 deletions(-)
|
||||
create mode 100644 daemon/libvirt.rules
|
||||
|
||||
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
|
||||
index b95a79d..9c5ea37 100644
|
||||
--- a/daemon/Makefile.am
|
||||
+++ b/daemon/Makefile.am
|
||||
@@ -53,6 +53,7 @@ EXTRA_DIST = \
|
||||
libvirtd.init.in \
|
||||
libvirtd.upstart \
|
||||
libvirtd.policy.in \
|
||||
+ libvirt.rules \
|
||||
libvirtd.sasl \
|
||||
libvirtd.service.in \
|
||||
libvirtd.socket.in \
|
||||
@@ -233,6 +234,8 @@ policyauth = auth_admin_keep_session
|
||||
else ! WITH_POLKIT0
|
||||
policydir = $(datadir)/polkit-1/actions
|
||||
policyauth = auth_admin_keep
|
||||
+rulesdir = $(datadir)/polkit-1/rules.d
|
||||
+rulesfile = libvirt.rules
|
||||
endif ! WITH_POLKIT0
|
||||
endif WITH_POLKIT
|
||||
|
||||
@@ -263,9 +266,19 @@ if WITH_POLKIT
|
||||
install-data-polkit::
|
||||
$(MKDIR_P) $(DESTDIR)$(policydir)
|
||||
$(INSTALL_DATA) libvirtd.policy $(DESTDIR)$(policydir)/org.libvirt.unix.policy
|
||||
+if ! WITH_POLKIT0
|
||||
+ $(MKDIR_P) $(DESTDIR)$(rulesdir)
|
||||
+ $(INSTALL_DATA) $(srcdir)/$(rulesfile) $(DESTDIR)$(rulesdir)/50-libvirt.rules
|
||||
+endif ! WITH_POLKIT0
|
||||
+
|
||||
uninstall-data-polkit::
|
||||
rm -f $(DESTDIR)$(policydir)/org.libvirt.unix.policy
|
||||
rmdir $(DESTDIR)$(policydir) || :
|
||||
+if ! WITH_POLKIT0
|
||||
+ rm -f $(DESTDIR)$(rulesdir)/50-libvirt.rules
|
||||
+ rmdir $(DESTDIR)$(rulesdir) || :
|
||||
+endif ! WITH_POLKIT0
|
||||
+
|
||||
else ! WITH_POLKIT
|
||||
install-data-polkit::
|
||||
uninstall-data-polkit::
|
||||
diff --git a/daemon/libvirt.rules b/daemon/libvirt.rules
|
||||
new file mode 100644
|
||||
index 0000000..01a15fa
|
||||
--- /dev/null
|
||||
+++ b/daemon/libvirt.rules
|
||||
@@ -0,0 +1,9 @@
|
||||
+// Allow any user in the 'libvirt' group to connect to system libvirtd
|
||||
+// without entering a password.
|
||||
+
|
||||
+polkit.addRule(function(action, subject) {
|
||||
+ if (action.id == "org.libvirt.unix.manage" &&
|
||||
+ subject.isInGroup("libvirt")) {
|
||||
+ return polkit.Result.YES;
|
||||
+ }
|
||||
+});
|
||||
diff --git a/libvirt.spec.in b/libvirt.spec.in
|
||||
index a84b19d..5de085b 100644
|
||||
--- a/libvirt.spec.in
|
||||
+++ b/libvirt.spec.in
|
||||
@@ -1583,9 +1583,9 @@ then
|
||||
fi
|
||||
|
||||
%if %{with_libvirtd}
|
||||
+%pre daemon
|
||||
%if ! %{with_driver_modules}
|
||||
%if %{with_qemu}
|
||||
-%pre daemon
|
||||
%if 0%{?fedora} || 0%{?rhel} >= 6
|
||||
# We want soft static allocation of well-known ids, as disk images
|
||||
# are commonly shared across NFS mounts by id rather than name; see
|
||||
@@ -1599,11 +1599,21 @@ if ! getent passwd qemu >/dev/null; then
|
||||
useradd -r -g qemu -G kvm -d / -s /sbin/nologin -c "qemu user" qemu
|
||||
fi
|
||||
fi
|
||||
-exit 0
|
||||
%endif
|
||||
%endif
|
||||
%endif
|
||||
|
||||
+ %if %{with_polkit}
|
||||
+ %if 0%{?fedora} || 0%{?rhel} >= 6
|
||||
+# 'libvirt' group is just to allow password-less polkit access to
|
||||
+# libvirtd. The uid number is irrelevant, so we use dynamic allocation
|
||||
+# described at the above link.
|
||||
+getent group libvirt >/dev/null || groupadd -r libvirt
|
||||
+ %endif
|
||||
+ %endif
|
||||
+
|
||||
+exit 0
|
||||
+
|
||||
%post daemon
|
||||
|
||||
%if %{with_network}
|
||||
@@ -1919,6 +1929,7 @@ exit 0
|
||||
%if 0%{?fedora} || 0%{?rhel} >= 6
|
||||
%{_datadir}/polkit-1/actions/org.libvirt.unix.policy
|
||||
%{_datadir}/polkit-1/actions/org.libvirt.api.policy
|
||||
+%{_datadir}/polkit-1/rules.d/50-libvirt.rules
|
||||
%else
|
||||
%{_datadir}/PolicyKit/policy/org.libvirt.unix.policy
|
||||
%endif
|
||||
@@ -1,225 +0,0 @@
|
||||
Return-Path: alexl@redhat.com
|
||||
Received: from zmta04.collab.prod.int.phx2.redhat.com (LHLO
|
||||
zmta04.collab.prod.int.phx2.redhat.com) (10.5.81.11) by
|
||||
zmail20.collab.prod.int.phx2.redhat.com with LMTP; Tue, 9 Oct 2012 11:26:38
|
||||
-0400 (EDT)
|
||||
Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23])
|
||||
by zmta04.collab.prod.int.phx2.redhat.com (Postfix) with ESMTP id D4096D0927
|
||||
for <alexl@mail.corp.redhat.com>; Tue, 9 Oct 2012 11:26:38 -0400 (EDT)
|
||||
Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1])
|
||||
by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q99FQV93016417;
|
||||
Tue, 9 Oct 2012 11:26:33 -0400
|
||||
From: Alexander Larsson <alexl@redhat.com>
|
||||
To: libvir-list@redhat.com
|
||||
Cc: Alexander Larsson <alexl@redhat.com>
|
||||
Subject: [PATCH 1/2] virdbus: Add virDBusGetSessionBus helper
|
||||
Date: Tue, 9 Oct 2012 17:26:28 +0200
|
||||
Message-Id: <1349796389-6122-2-git-send-email-alexl@redhat.com>
|
||||
In-Reply-To: <1349796389-6122-1-git-send-email-alexl@redhat.com>
|
||||
References: <1349796389-6122-1-git-send-email-alexl@redhat.com>
|
||||
X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23
|
||||
|
||||
This splits out some common code from virDBusGetSystemBus and
|
||||
uses it to implement a new virDBusGetSessionBus helper.
|
||||
---
|
||||
src/libvirt_private.syms | 1 +
|
||||
src/util/virdbus.c | 84 ++++++++++++++++++++++++++++++++++++------------
|
||||
src/util/virdbus.h | 1 +
|
||||
3 files changed, 66 insertions(+), 20 deletions(-)
|
||||
|
||||
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
|
||||
index a8c81e7..88f1b2f 100644
|
||||
--- a/src/libvirt_private.syms
|
||||
+++ b/src/libvirt_private.syms
|
||||
@@ -1310,6 +1310,7 @@ virConsoleOpen;
|
||||
|
||||
# virdbus.h
|
||||
virDBusGetSystemBus;
|
||||
+virDBusGetSessionBus;
|
||||
|
||||
|
||||
# virdomainlist.h
|
||||
diff --git a/src/util/virdbus.c b/src/util/virdbus.c
|
||||
index 4acce12..2dc7265 100644
|
||||
--- a/src/util/virdbus.c
|
||||
+++ b/src/util/virdbus.c
|
||||
@@ -32,40 +32,49 @@
|
||||
#ifdef HAVE_DBUS
|
||||
|
||||
static DBusConnection *systembus = NULL;
|
||||
-static virOnceControl once = VIR_ONCE_CONTROL_INITIALIZER;
|
||||
-static DBusError dbuserr;
|
||||
+static DBusConnection *sessionbus = NULL;
|
||||
+static virOnceControl systemonce = VIR_ONCE_CONTROL_INITIALIZER;
|
||||
+static virOnceControl sessiononce = VIR_ONCE_CONTROL_INITIALIZER;
|
||||
+static DBusError systemdbuserr;
|
||||
+static DBusError sessiondbuserr;
|
||||
|
||||
static dbus_bool_t virDBusAddWatch(DBusWatch *watch, void *data);
|
||||
static void virDBusRemoveWatch(DBusWatch *watch, void *data);
|
||||
static void virDBusToggleWatch(DBusWatch *watch, void *data);
|
||||
|
||||
-static void virDBusSystemBusInit(void)
|
||||
+static DBusConnection *virDBusBusInit(DBusBusType type, DBusError *dbuserr)
|
||||
{
|
||||
+ DBusConnection *bus;
|
||||
+
|
||||
/* Allocate and initialize a new HAL context */
|
||||
dbus_connection_set_change_sigpipe(FALSE);
|
||||
dbus_threads_init_default();
|
||||
|
||||
- dbus_error_init(&dbuserr);
|
||||
- if (!(systembus = dbus_bus_get(DBUS_BUS_SYSTEM, &dbuserr)))
|
||||
- return;
|
||||
+ dbus_error_init(dbuserr);
|
||||
+ if (!(bus = dbus_bus_get(type, dbuserr)))
|
||||
+ return NULL;
|
||||
|
||||
- dbus_connection_set_exit_on_disconnect(systembus, FALSE);
|
||||
+ dbus_connection_set_exit_on_disconnect(bus, FALSE);
|
||||
|
||||
/* Register dbus watch callbacks */
|
||||
- if (!dbus_connection_set_watch_functions(systembus,
|
||||
+ if (!dbus_connection_set_watch_functions(bus,
|
||||
virDBusAddWatch,
|
||||
virDBusRemoveWatch,
|
||||
virDBusToggleWatch,
|
||||
- NULL, NULL)) {
|
||||
- systembus = NULL;
|
||||
- return;
|
||||
+ bus, NULL)) {
|
||||
+ return NULL;
|
||||
}
|
||||
+ return bus;
|
||||
}
|
||||
|
||||
+static void virDBusSystemBusInit(void)
|
||||
+{
|
||||
+ systembus = virDBusBusInit (DBUS_BUS_SYSTEM, &systemdbuserr);
|
||||
+}
|
||||
|
||||
DBusConnection *virDBusGetSystemBus(void)
|
||||
{
|
||||
- if (virOnce(&once, virDBusSystemBusInit) < 0) {
|
||||
+ if (virOnce(&systemonce, virDBusSystemBusInit) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("Unable to run one time DBus initializer"));
|
||||
return NULL;
|
||||
@@ -74,7 +83,7 @@ DBusConnection *virDBusGetSystemBus(void)
|
||||
if (!systembus) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Unable to get DBus system bus connection: %s"),
|
||||
- dbuserr.message ? dbuserr.message : "watch setup failed");
|
||||
+ systemdbuserr.message ? systemdbuserr.message : "watch setup failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -82,13 +91,45 @@ DBusConnection *virDBusGetSystemBus(void)
|
||||
}
|
||||
|
||||
|
||||
+static void virDBusSessionBusInit(void)
|
||||
+{
|
||||
+ sessionbus = virDBusBusInit (DBUS_BUS_SESSION, &sessiondbuserr);
|
||||
+}
|
||||
+
|
||||
+DBusConnection *virDBusGetSessionBus(void)
|
||||
+{
|
||||
+ if (virOnce(&sessiononce, virDBusSessionBusInit) < 0) {
|
||||
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
+ _("Unable to run one time DBus initializer"));
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ if (!sessionbus) {
|
||||
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
+ _("Unable to get DBus session bus connection: %s"),
|
||||
+ sessiondbuserr.message ? sessiondbuserr.message : "watch setup failed");
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ return sessionbus;
|
||||
+}
|
||||
+
|
||||
+struct virDBusWatch
|
||||
+{
|
||||
+ int watch;
|
||||
+ DBusConnection *bus;
|
||||
+};
|
||||
+
|
||||
static void virDBusWatchCallback(int fdatch ATTRIBUTE_UNUSED,
|
||||
int fd ATTRIBUTE_UNUSED,
|
||||
int events, void *opaque)
|
||||
{
|
||||
DBusWatch *watch = opaque;
|
||||
+ struct virDBusWatch *info;
|
||||
int dbus_flags = 0;
|
||||
|
||||
+ info = dbus_watch_get_data(watch);
|
||||
+
|
||||
if (events & VIR_EVENT_HANDLE_READABLE)
|
||||
dbus_flags |= DBUS_WATCH_READABLE;
|
||||
if (events & VIR_EVENT_HANDLE_WRITABLE)
|
||||
@@ -100,7 +141,7 @@ static void virDBusWatchCallback(int fdatch ATTRIBUTE_UNUSED,
|
||||
|
||||
(void)dbus_watch_handle(watch, dbus_flags);
|
||||
|
||||
- while (dbus_connection_dispatch(systembus) == DBUS_DISPATCH_DATA_REMAINS)
|
||||
+ while (dbus_connection_dispatch(info->bus) == DBUS_DISPATCH_DATA_REMAINS)
|
||||
/* keep dispatching while data remains */;
|
||||
}
|
||||
|
||||
@@ -120,18 +161,13 @@ static int virDBusTranslateWatchFlags(int dbus_flags)
|
||||
}
|
||||
|
||||
|
||||
-struct virDBusWatch
|
||||
-{
|
||||
- int watch;
|
||||
-};
|
||||
-
|
||||
static void virDBusWatchFree(void *data) {
|
||||
struct virDBusWatch *info = data;
|
||||
VIR_FREE(info);
|
||||
}
|
||||
|
||||
static dbus_bool_t virDBusAddWatch(DBusWatch *watch,
|
||||
- void *data ATTRIBUTE_UNUSED)
|
||||
+ void *data)
|
||||
{
|
||||
int flags = 0;
|
||||
int fd;
|
||||
@@ -148,6 +184,7 @@ static dbus_bool_t virDBusAddWatch(DBusWatch *watch,
|
||||
# else
|
||||
fd = dbus_watch_get_fd(watch);
|
||||
# endif
|
||||
+ info->bus = (DBusConnection *)data;
|
||||
info->watch = virEventAddHandle(fd, flags,
|
||||
virDBusWatchCallback,
|
||||
watch, NULL);
|
||||
@@ -194,4 +231,11 @@ DBusConnection *virDBusGetSystemBus(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+DBusConnection *virDBusGetSessionBus(void)
|
||||
+{
|
||||
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
+ "%s", _("DBus support not compiled into this binary"));
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
#endif /* ! HAVE_DBUS */
|
||||
diff --git a/src/util/virdbus.h b/src/util/virdbus.h
|
||||
index 27dca00..e443fbe 100644
|
||||
--- a/src/util/virdbus.h
|
||||
+++ b/src/util/virdbus.h
|
||||
@@ -30,5 +30,6 @@
|
||||
# include "internal.h"
|
||||
|
||||
DBusConnection *virDBusGetSystemBus(void);
|
||||
+DBusConnection *virDBusGetSessionBus(void);
|
||||
|
||||
#endif /* __VIR_DBUS_H__ */
|
||||
--
|
||||
1.7.12.1
|
||||
|
||||
@@ -1,303 +0,0 @@
|
||||
Return-Path: alexl@redhat.com
|
||||
Received: from zmta06.collab.prod.int.phx2.redhat.com (LHLO
|
||||
zmta06.collab.prod.int.phx2.redhat.com) (10.5.81.13) by
|
||||
zmail20.collab.prod.int.phx2.redhat.com with LMTP; Tue, 9 Oct 2012 11:26:39
|
||||
-0400 (EDT)
|
||||
Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23])
|
||||
by zmta06.collab.prod.int.phx2.redhat.com (Postfix) with ESMTP id D4A8516044F
|
||||
for <alexl@mail.corp.redhat.com>; Tue, 9 Oct 2012 11:26:39 -0400 (EDT)
|
||||
Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1])
|
||||
by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q99FQV94016417;
|
||||
Tue, 9 Oct 2012 11:26:34 -0400
|
||||
From: Alexander Larsson <alexl@redhat.com>
|
||||
To: libvir-list@redhat.com
|
||||
Cc: Alexander Larsson <alexl@redhat.com>
|
||||
Subject: [PATCH 2/2] Shut down session libvirtd cleanly
|
||||
Date: Tue, 9 Oct 2012 17:26:29 +0200
|
||||
Message-Id: <1349796389-6122-3-git-send-email-alexl@redhat.com>
|
||||
In-Reply-To: <1349796389-6122-1-git-send-email-alexl@redhat.com>
|
||||
References: <1349796389-6122-1-git-send-email-alexl@redhat.com>
|
||||
X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23
|
||||
|
||||
When the session dies or when the system is going to be shut down
|
||||
we save all active VMs and exit libvirtd.
|
||||
|
||||
Additionally whenever there is an active domain we hold a
|
||||
shutdown inhibitor to avoid shutting down before all the
|
||||
VMs are saved.
|
||||
---
|
||||
daemon/libvirtd.c | 244 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 244 insertions(+)
|
||||
|
||||
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
|
||||
index b49acc5..c3bf2ce 100644
|
||||
--- a/daemon/libvirtd.c
|
||||
+++ b/daemon/libvirtd.c
|
||||
@@ -98,6 +98,11 @@
|
||||
|
||||
#include "configmake.h"
|
||||
|
||||
+#ifdef HAVE_DBUS
|
||||
+# include <dbus/dbus.h>
|
||||
+# include "virdbus.h"
|
||||
+#endif
|
||||
+
|
||||
#if HAVE_SASL
|
||||
virNetSASLContextPtr saslCtxt = NULL;
|
||||
#endif
|
||||
@@ -769,6 +774,212 @@ static int daemonSetupSignals(virNetServerPtr srv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
+#ifdef HAVE_DBUS
|
||||
+
|
||||
+static DBusConnection *sessionBus;
|
||||
+static DBusConnection *systemBus;
|
||||
+static virConnectPtr sessionConnection;
|
||||
+static int numActiveDomains;
|
||||
+static bool hasInhibit;
|
||||
+static bool callingInhibit;
|
||||
+static int inhibitFd = -1;
|
||||
+
|
||||
+static void runSaveAllDomains(void *opaque)
|
||||
+{
|
||||
+ virNetServerPtr srv = opaque;
|
||||
+ int numDomains, i;
|
||||
+ int state;
|
||||
+ virDomainPtr *domains = NULL;
|
||||
+ unsigned int *flags = NULL;
|
||||
+
|
||||
+ numDomains = virConnectListAllDomains(sessionConnection, &domains, VIR_CONNECT_LIST_DOMAINS_ACTIVE);
|
||||
+ if (numDomains < 0)
|
||||
+ goto cleanup;
|
||||
+
|
||||
+ if (VIR_ALLOC_N(flags, numDomains) < 0) {
|
||||
+ virReportOOMError();
|
||||
+ goto cleanup;
|
||||
+ }
|
||||
+
|
||||
+ /* First we pause all VMs to make them stop dirtying
|
||||
+ pages, etc. We remember if any VMs were paused so
|
||||
+ we can restore that on resume. */
|
||||
+ for (i = 0 ; i < numDomains ; i++) {
|
||||
+ flags[i] = VIR_DOMAIN_SAVE_RUNNING;
|
||||
+ if (virDomainGetState (domains[i], &state, NULL, 0) == 0) {
|
||||
+ if (state == VIR_DOMAIN_PAUSED) {
|
||||
+ flags[i] = VIR_DOMAIN_SAVE_PAUSED;
|
||||
+ }
|
||||
+ }
|
||||
+ virDomainSuspend (domains[i]);
|
||||
+ }
|
||||
+
|
||||
+ /* Then we save the VMs to disk */
|
||||
+ for (i = 0 ; i < numDomains ; i++)
|
||||
+ virDomainManagedSave (domains[i], flags[i]);
|
||||
+
|
||||
+ VIR_FREE (domains);
|
||||
+ VIR_FREE (flags);
|
||||
+
|
||||
+ cleanup:
|
||||
+ if (domains != NULL) {
|
||||
+ for (i = 0 ; i < numDomains ; i++)
|
||||
+ virDomainFree (domains[i]);
|
||||
+ VIR_FREE (domains);
|
||||
+ }
|
||||
+ if (flags != NULL)
|
||||
+ VIR_FREE (flags);
|
||||
+
|
||||
+ /* We don't need any shutdown inhibit lock anymore now */
|
||||
+ if (inhibitFd != -1) {
|
||||
+ if (VIR_CLOSE (inhibitFd) < 0)
|
||||
+ virReportSystemError(errno, "%s", _("failed to close file"));
|
||||
+ inhibitFd = -1;
|
||||
+ }
|
||||
+
|
||||
+ /* Exit libvirtd cleanly */
|
||||
+ virNetServerQuit (srv);
|
||||
+}
|
||||
+
|
||||
+/* We do this in a thread to not block the main loop */
|
||||
+static void saveAllDomains(virNetServerPtr srv)
|
||||
+{
|
||||
+ virThread thr;
|
||||
+ virObjectRef(srv);
|
||||
+ if (virThreadCreate(&thr, false, runSaveAllDomains, srv) < 0) {
|
||||
+ virObjectUnref(srv);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void gotInhibitReply (DBusPendingCall *pending,
|
||||
+ void *opaque ATTRIBUTE_UNUSED)
|
||||
+{
|
||||
+ DBusMessage *reply;
|
||||
+ int fd;
|
||||
+
|
||||
+ callingInhibit = false;
|
||||
+
|
||||
+ reply = dbus_pending_call_steal_reply (pending);
|
||||
+ if (reply == NULL)
|
||||
+ return;
|
||||
+
|
||||
+ if (dbus_message_get_args (reply, NULL,
|
||||
+ DBUS_TYPE_UNIX_FD, &fd,
|
||||
+ DBUS_TYPE_INVALID)) {
|
||||
+ if (hasInhibit)
|
||||
+ inhibitFd = fd;
|
||||
+ else {
|
||||
+ /* We stopped the last VM since we made the inhibit call */
|
||||
+ if (VIR_CLOSE (fd) < 0) {
|
||||
+ virReportSystemError(errno, "%s", _("failed to close file"));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ dbus_message_unref (reply);
|
||||
+}
|
||||
+
|
||||
+/* As per: http://www.freedesktop.org/wiki/Software/systemd/inhibit */
|
||||
+static void callInhibit(const char *what,
|
||||
+ const char *who,
|
||||
+ const char *why,
|
||||
+ const char *mode)
|
||||
+{
|
||||
+ DBusMessage *message;
|
||||
+ DBusPendingCall *pendingReply;
|
||||
+
|
||||
+ if (systemBus == NULL)
|
||||
+ return;
|
||||
+
|
||||
+ /* Only one outstanding call at a time */
|
||||
+ if (callingInhibit)
|
||||
+ return;
|
||||
+
|
||||
+ message = dbus_message_new_method_call ("org.freedesktop.login1",
|
||||
+ "/org/freedesktop/login1",
|
||||
+ "org.freedesktop.login1.Manager",
|
||||
+ "Inhibit");
|
||||
+ if (message == NULL)
|
||||
+ return;
|
||||
+
|
||||
+ dbus_message_append_args (message,
|
||||
+ DBUS_TYPE_STRING, &what,
|
||||
+ DBUS_TYPE_STRING, &who,
|
||||
+ DBUS_TYPE_STRING, &why,
|
||||
+ DBUS_TYPE_STRING, &mode,
|
||||
+ DBUS_TYPE_INVALID);
|
||||
+
|
||||
+ pendingReply = NULL;
|
||||
+ if (dbus_connection_send_with_reply (systemBus, message,
|
||||
+ &pendingReply,
|
||||
+ 25*1000)) {
|
||||
+ dbus_pending_call_set_notify (pendingReply,
|
||||
+ gotInhibitReply,
|
||||
+ NULL, NULL);
|
||||
+ callingInhibit = true;
|
||||
+ }
|
||||
+ dbus_message_unref (message);
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static void numActiveDomainsChanged(void)
|
||||
+{
|
||||
+ if (numActiveDomains > 0 && !hasInhibit) {
|
||||
+ callInhibit("shutdown", _("Libvirt"), _("Virtual machines need to be saved"), "delay");
|
||||
+ hasInhibit = true;
|
||||
+ } else if (numActiveDomains == 0 && hasInhibit) {
|
||||
+ if (inhibitFd != -1) {
|
||||
+ if (VIR_CLOSE (inhibitFd) < 0) {
|
||||
+ virReportSystemError(errno, "%s", _("failed to close file"));
|
||||
+ }
|
||||
+ inhibitFd = -1;
|
||||
+ }
|
||||
+ hasInhibit = false;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int lifecycleEventCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||
+ virDomainPtr dom ATTRIBUTE_UNUSED,
|
||||
+ int event,
|
||||
+ int detail ATTRIBUTE_UNUSED,
|
||||
+ void *opaque ATTRIBUTE_UNUSED)
|
||||
+{
|
||||
+ if (event == VIR_DOMAIN_EVENT_STOPPED)
|
||||
+ numActiveDomains--;
|
||||
+ else if (event == VIR_DOMAIN_EVENT_STARTED)
|
||||
+ numActiveDomains++;
|
||||
+
|
||||
+ numActiveDomainsChanged();
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static DBusHandlerResult handleSessionMessageFunc(DBusConnection *connection ATTRIBUTE_UNUSED,
|
||||
+ DBusMessage *message,
|
||||
+ void *userData)
|
||||
+{
|
||||
+ virNetServerPtr srv = userData;
|
||||
+
|
||||
+ if (dbus_message_is_signal(message, DBUS_INTERFACE_LOCAL, "Disconnected")) {
|
||||
+ saveAllDomains (srv);
|
||||
+ }
|
||||
+
|
||||
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
||||
+}
|
||||
+
|
||||
+static DBusHandlerResult handleSystemMessageFunc(DBusConnection *connection ATTRIBUTE_UNUSED,
|
||||
+ DBusMessage *message,
|
||||
+ void *userData)
|
||||
+{
|
||||
+ virNetServerPtr srv = userData;
|
||||
+
|
||||
+ if (dbus_message_is_signal(message, "org.freedesktop.login1.Manager", "PrepareForShutdown")) {
|
||||
+ saveAllDomains (srv);
|
||||
+ }
|
||||
+
|
||||
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
static void daemonRunStateInit(void *opaque)
|
||||
{
|
||||
virNetServerPtr srv = opaque;
|
||||
@@ -785,6 +996,39 @@ static void daemonRunStateInit(void *opaque)
|
||||
return;
|
||||
}
|
||||
|
||||
+#ifdef HAVE_DBUS
|
||||
+ /* Tie the non-priviledged libvirtd to the session/shutdown lifecycle */
|
||||
+ if (!virNetServerIsPrivileged(srv)) {
|
||||
+
|
||||
+ sessionBus = virDBusGetSessionBus ();
|
||||
+ if (sessionBus != NULL) {
|
||||
+ dbus_connection_add_filter(sessionBus,
|
||||
+ handleSessionMessageFunc, srv, NULL);
|
||||
+ }
|
||||
+
|
||||
+ systemBus = virDBusGetSystemBus ();
|
||||
+ if (systemBus != NULL) {
|
||||
+ dbus_connection_add_filter(systemBus,
|
||||
+ handleSystemMessageFunc, srv, NULL);
|
||||
+ dbus_bus_add_match(systemBus,
|
||||
+ "type='signal',sender='org.freedesktop.login1', interface='org.freedesktop.login1.Manager'",
|
||||
+ NULL);
|
||||
+ }
|
||||
+
|
||||
+ sessionConnection = virConnectOpen("qemu:///session");
|
||||
+ if (sessionConnection != NULL) {
|
||||
+ numActiveDomains = virConnectNumOfDomains(sessionConnection);
|
||||
+ virConnectDomainEventRegisterAny(sessionConnection,
|
||||
+ NULL,
|
||||
+ VIR_DOMAIN_EVENT_ID_LIFECYCLE,
|
||||
+ VIR_DOMAIN_EVENT_CALLBACK (lifecycleEventCallback),
|
||||
+ NULL, NULL);
|
||||
+ numActiveDomainsChanged();
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
/* Only now accept clients from network */
|
||||
virNetServerUpdateServices(srv, true);
|
||||
virObjectUnref(srv);
|
||||
--
|
||||
1.7.12.1
|
||||
|
||||
+1205
-692
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user