SHA256
1
0
forked from pool/libvirt

Accepting request 569996 from home:jfehlig:branches:Virtualization

- qemu: Support setting OEM strings in SMBIOS
  68eed56b-conf-smbios-oem-strings.patch,
  76977061-qemu-smbios-oem-strings.patch
  FATE#323624
- libxl: resume lock process after failed migration
  0c710a37-libxl-resume-lock-on-mig-failure.patch
  bsc#1076861

- qemu hook: Change shebang to /usr/bin/python3
- spec: Require python lxml in daemon-hooks subpackage

OBS-URL: https://build.opensuse.org/request/show/569996
OBS-URL: https://build.opensuse.org/package/show/Virtualization/libvirt?expand=0&rev=665
This commit is contained in:
James Fehlig 2018-01-26 17:16:35 +00:00 committed by Git OBS Bridge
parent 14ffab8d40
commit a48acb127a
7 changed files with 433 additions and 3 deletions

View File

@ -0,0 +1,52 @@
commit 0c710a37ea265dc7dfa0ebcebf1e21e4c6b2ea21
Author: Jim Fehlig <jfehlig@suse.com>
Date: Wed Jan 24 14:23:04 2018 -0700
libxl: resume lock process after failed migration
During migration, the lock process is paused in the perform phase
but not resumed if there is a subsequent failure, leaving the locked
resource unprotected.
The perform phase itself can fail, in which case the lock process
should be resumed before returning from perform. The finish phase
could also fail on the destination host, in which case the migration
is canceled in the confirm phase and the VM is resumed. The lock
process needs to be resumed there as well.
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Index: libvirt-4.0.0/src/libxl/libxl_migration.c
===================================================================
--- libvirt-4.0.0.orig/src/libxl/libxl_migration.c
+++ libvirt-4.0.0/src/libxl/libxl_migration.c
@@ -1238,6 +1238,12 @@ libxlDomainMigrationPerform(libxlDriverP
ret = libxlDoMigrateSend(driver, vm, flags, sockfd);
virObjectLock(vm);
+ if (ret < 0)
+ virDomainLockProcessResume(driver->lockManager,
+ "xen:///system",
+ vm,
+ priv->lockState);
+
cleanup:
VIR_FORCE_CLOSE(sockfd);
virURIFree(uri);
@@ -1349,10 +1355,16 @@ libxlDomainMigrationConfirm(libxlDriverP
int cancelled)
{
libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
+ libxlDomainObjPrivatePtr priv = vm->privateData;
virObjectEventPtr event = NULL;
int ret = -1;
if (cancelled) {
+ /* Resume lock process that was paused in MigrationPerform */
+ virDomainLockProcessResume(driver->lockManager,
+ "xen:///system",
+ vm,
+ priv->lockState);
if (libxl_domain_resume(cfg->ctx, vm->def->id, 1, 0) == 0) {
ret = 0;
} else {

View File

@ -0,0 +1,245 @@
commit 68eed56b2d51e66bb540062fe09f5ffd44e99f6e
Author: Daniel P. Berrange <berrange@redhat.com>
Date: Sat Oct 28 14:56:51 2017 +0100
conf: add support for setting OEM strings SMBIOS data fields
The OEM strings table in SMBIOS allows the vendor to pass arbitrary
strings into the guest OS. This can be used as a way to pass data to an
application like cloud-init, or potentially as an alternative to the
kernel command line for OS installers where you can't modify the install
ISO image to change the kernel args.
As an example, consider if cloud-init and anaconda supported OEM strings
you could use something like
<oemStrings>
<entry>cloud-init:ds=nocloud-net;s=http://10.10.0.1:8000/</entry>
<entry>anaconda:method=http://dl.fedoraproject.org/pub/fedora/linux/releases/25/x86_64/os</entry>
</oemStrings>
use of a application specific prefix as illustrated above is
recommended, but not mandated, so that an app can reliably identify
which of the many OEM strings are targetted at it.
Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Index: libvirt-4.0.0/docs/formatdomain.html.in
===================================================================
--- libvirt-4.0.0.orig/docs/formatdomain.html.in
+++ libvirt-4.0.0/docs/formatdomain.html.in
@@ -411,6 +411,10 @@
&lt;entry name='version'&gt;0B98401 Pro&lt;/entry&gt;
&lt;entry name='serial'&gt;W1KS427111E&lt;/entry&gt;
&lt;/baseBoard&gt;
+ &lt;oemStrings&gt;
+ &lt;entry&gt;myappname:some arbitrary data&lt;/entry&gt;
+ &lt;entry&gt;otherappname:more arbitrary data&lt;/entry&gt;
+ &lt;/oemStrings&gt;
&lt;/sysinfo&gt;
...</pre>
@@ -498,6 +502,15 @@
validation and <code>date</code> format checking, all values are
passed as strings to the hypervisor driver.
</dd>
+ <dt><code>oemStrings</code></dt>
+ <dd>
+ This is block 11 of SMBIOS. This element should appear once and
+ can have multiple <code>entry</code> child elements, each providing
+ arbitrary string data. There are no restrictions on what data can
+ be provided in the entries, however, if the data is intended to be
+ consumed by an application in the guest, it is recommended to use
+ the application name as a prefix in the string. (<span class="since">Since 4.1.0</span>)
+ </dd>
</dl>
</dd>
</dl>
Index: libvirt-4.0.0/docs/schemas/domaincommon.rng
===================================================================
--- libvirt-4.0.0.orig/docs/schemas/domaincommon.rng
+++ libvirt-4.0.0/docs/schemas/domaincommon.rng
@@ -4857,6 +4857,15 @@
</oneOrMore>
</element>
</zeroOrMore>
+ <optional>
+ <element name="oemStrings">
+ <oneOrMore>
+ <element name="entry">
+ <ref name="sysinfo-value"/>
+ </element>
+ </oneOrMore>
+ </element>
+ </optional>
</interleave>
</element>
</define>
Index: libvirt-4.0.0/src/conf/domain_conf.c
===================================================================
--- libvirt-4.0.0.orig/src/conf/domain_conf.c
+++ libvirt-4.0.0/src/conf/domain_conf.c
@@ -14461,6 +14461,42 @@ virSysinfoBaseBoardParseXML(xmlXPathCont
return ret;
}
+
+static int
+virSysinfoOEMStringsParseXML(xmlXPathContextPtr ctxt,
+ virSysinfoOEMStringsDefPtr *oem)
+{
+ int ret = -1;
+ virSysinfoOEMStringsDefPtr def;
+ xmlNodePtr *strings = NULL;
+ int nstrings;
+ size_t i;
+
+ nstrings = virXPathNodeSet("./entry", ctxt, &strings);
+ if (nstrings < 0)
+ return -1;
+ if (nstrings == 0)
+ return 0;
+
+ if (VIR_ALLOC(def) < 0)
+ goto cleanup;
+
+ if (VIR_ALLOC_N(def->values, nstrings) < 0)
+ goto cleanup;
+
+ def->nvalues = nstrings;
+ for (i = 0; i < nstrings; i++)
+ def->values[i] = virXMLNodeContentString(strings[i]);
+
+ *oem = def;
+ def = NULL;
+ ret = 0;
+ cleanup:
+ VIR_FREE(strings);
+ virSysinfoOEMStringsDefFree(def);
+ return ret;
+}
+
static virSysinfoDefPtr
virSysinfoParseXML(xmlNodePtr node,
xmlXPathContextPtr ctxt,
@@ -14519,6 +14555,17 @@ virSysinfoParseXML(xmlNodePtr node,
if (virSysinfoBaseBoardParseXML(ctxt, &def->baseBoard, &def->nbaseBoard) < 0)
goto error;
+ /* Extract system related metadata */
+ if ((tmpnode = virXPathNode("./oemStrings[1]", ctxt)) != NULL) {
+ oldnode = ctxt->node;
+ ctxt->node = tmpnode;
+ if (virSysinfoOEMStringsParseXML(ctxt, &def->oemStrings) < 0) {
+ ctxt->node = oldnode;
+ goto error;
+ }
+ ctxt->node = oldnode;
+ }
+
cleanup:
VIR_FREE(type);
return def;
Index: libvirt-4.0.0/src/util/virsysinfo.c
===================================================================
--- libvirt-4.0.0.orig/src/util/virsysinfo.c
+++ libvirt-4.0.0/src/util/virsysinfo.c
@@ -108,6 +108,20 @@ void virSysinfoBaseBoardDefClear(virSysi
VIR_FREE(def->location);
}
+void virSysinfoOEMStringsDefFree(virSysinfoOEMStringsDefPtr def)
+{
+ size_t i;
+
+ if (def == NULL)
+ return;
+
+ for (i = 0; i < def->nvalues; i++)
+ VIR_FREE(def->values[i]);
+ VIR_FREE(def->values);
+
+ VIR_FREE(def);
+}
+
/**
* virSysinfoDefFree:
* @def: a sysinfo structure
@@ -157,6 +171,8 @@ void virSysinfoDefFree(virSysinfoDefPtr
}
VIR_FREE(def->memory);
+ virSysinfoOEMStringsDefFree(def->oemStrings);
+
VIR_FREE(def);
}
@@ -1294,6 +1310,24 @@ virSysinfoMemoryFormat(virBufferPtr buf,
}
}
+static void
+virSysinfoOEMStringsFormat(virBufferPtr buf, virSysinfoOEMStringsDefPtr def)
+{
+ size_t i;
+
+ if (!def)
+ return;
+
+ virBufferAddLit(buf, "<oemStrings>\n");
+ virBufferAdjustIndent(buf, 2);
+ for (i = 0; i < def->nvalues; i++) {
+ virBufferEscapeString(buf, "<entry>%s</entry>\n",
+ def->values[i]);
+ }
+ virBufferAdjustIndent(buf, -2);
+ virBufferAddLit(buf, "</oemStrings>\n");
+}
+
/**
* virSysinfoFormat:
* @buf: buffer to append output to (may use auto-indentation)
@@ -1324,6 +1358,7 @@ virSysinfoFormat(virBufferPtr buf, virSy
virSysinfoBaseBoardFormat(&childrenBuf, def->baseBoard, def->nbaseBoard);
virSysinfoProcessorFormat(&childrenBuf, def);
virSysinfoMemoryFormat(&childrenBuf, def);
+ virSysinfoOEMStringsFormat(&childrenBuf, def->oemStrings);
virBufferAsprintf(buf, "<sysinfo type='%s'", type);
if (virBufferUse(&childrenBuf)) {
Index: libvirt-4.0.0/src/util/virsysinfo.h
===================================================================
--- libvirt-4.0.0.orig/src/util/virsysinfo.h
+++ libvirt-4.0.0/src/util/virsysinfo.h
@@ -98,6 +98,13 @@ struct _virSysinfoBaseBoardDef {
/* XXX board type */
};
+typedef struct _virSysinfoOEMStringsDef virSysinfoOEMStringsDef;
+typedef virSysinfoOEMStringsDef *virSysinfoOEMStringsDefPtr;
+struct _virSysinfoOEMStringsDef {
+ size_t nvalues;
+ char **values;
+};
+
typedef struct _virSysinfoDef virSysinfoDef;
typedef virSysinfoDef *virSysinfoDefPtr;
struct _virSysinfoDef {
@@ -114,6 +121,8 @@ struct _virSysinfoDef {
size_t nmemory;
virSysinfoMemoryDefPtr memory;
+
+ virSysinfoOEMStringsDefPtr oemStrings;
};
virSysinfoDefPtr virSysinfoRead(void);
@@ -121,6 +130,7 @@ virSysinfoDefPtr virSysinfoRead(void);
void virSysinfoBIOSDefFree(virSysinfoBIOSDefPtr def);
void virSysinfoSystemDefFree(virSysinfoSystemDefPtr def);
void virSysinfoBaseBoardDefClear(virSysinfoBaseBoardDefPtr def);
+void virSysinfoOEMStringsDefFree(virSysinfoOEMStringsDefPtr def);
void virSysinfoDefFree(virSysinfoDefPtr def);
int virSysinfoFormat(virBufferPtr buf, virSysinfoDefPtr def)

View File

@ -0,0 +1,110 @@
commit 7697706135562121732a5ddb5574a4afb269645f
Author: Daniel P. Berrange <berrange@redhat.com>
Date: Wed Jan 17 17:35:13 2018 +0000
qemu: add support for generating SMBIOS OEM strings command line
This wires up the previously added OEM strings XML schema to be able to
generate comamnd line args for QEMU. This requires QEMU >= 2.12 release
containing this patch:
commit 2d6dcbf93fb01b4a7f45a93d276d4d74b16392dd
Author: Daniel P. Berrange <berrange@redhat.com>
Date: Sat Oct 28 21:51:36 2017 +0100
smbios: support setting OEM strings table
Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Index: libvirt-4.0.0/src/qemu/qemu_command.c
===================================================================
--- libvirt-4.0.0.orig/src/qemu/qemu_command.c
+++ libvirt-4.0.0/src/qemu/qemu_command.c
@@ -6142,6 +6142,26 @@ qemuBuildSmbiosBaseBoardStr(virSysinfoBa
}
+static char *
+qemuBuildSmbiosOEMStringsStr(virSysinfoOEMStringsDefPtr def)
+{
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+ size_t i;
+
+ if (!def)
+ return NULL;
+
+ virBufferAddLit(&buf, "type=11");
+
+ for (i = 0; i < def->nvalues; i++) {
+ virBufferAddLit(&buf, ",value=");
+ virQEMUBuildBufferEscapeComma(&buf, def->values[i]);
+ }
+
+ return virBufferContentAndReset(&buf);
+}
+
+
static int
qemuBuildSmbiosCommandLine(virCommandPtr cmd,
virQEMUDriverPtr driver,
@@ -6210,6 +6230,14 @@ qemuBuildSmbiosCommandLine(virCommandPtr
return -1;
virCommandAddArgList(cmd, "-smbios", smbioscmd, NULL);
+ VIR_FREE(smbioscmd);
+ }
+
+ if (source->oemStrings) {
+ if (!(smbioscmd = qemuBuildSmbiosOEMStringsStr(source->oemStrings)))
+ return -1;
+
+ virCommandAddArgList(cmd, "-smbios", smbioscmd, NULL);
VIR_FREE(smbioscmd);
}
}
Index: libvirt-4.0.0/tests/qemuxml2argvdata/smbios.args
===================================================================
--- libvirt-4.0.0.orig/tests/qemuxml2argvdata/smbios.args
+++ libvirt-4.0.0/tests/qemuxml2argvdata/smbios.args
@@ -17,6 +17,8 @@ serial=32dfcb37-5af1-552b-357c-be8c3aa38
uuid=c7a5fdbd-edaf-9455-926a-d65c16db1809,sku=1234567890,family=Red Hat' \
-smbios 'type=2,manufacturer=Hewlett-Packard,product=0B4Ch,version=D,\
serial=CZC1065993,asset=CZC1065993,location=Upside down' \
+-smbios 'type=11,value=Hello,value=World,value=This is,,\
+ more tricky value=escaped' \
-nographic \
-nodefaults \
-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
Index: libvirt-4.0.0/tests/qemuxml2argvdata/smbios.xml
===================================================================
--- libvirt-4.0.0.orig/tests/qemuxml2argvdata/smbios.xml
+++ libvirt-4.0.0/tests/qemuxml2argvdata/smbios.xml
@@ -26,6 +26,11 @@
<entry name='asset'>CZC1065993</entry>
<entry name='location'>Upside down</entry>
</baseBoard>
+ <oemStrings>
+ <entry>Hello</entry>
+ <entry>World</entry>
+ <entry>This is, more tricky value=escaped</entry>
+ </oemStrings>
</sysinfo>
<os>
<type arch='i686' machine='pc'>hvm</type>
Index: libvirt-4.0.0/tests/qemuxml2xmloutdata/smbios.xml
===================================================================
--- libvirt-4.0.0.orig/tests/qemuxml2xmloutdata/smbios.xml
+++ libvirt-4.0.0/tests/qemuxml2xmloutdata/smbios.xml
@@ -26,6 +26,11 @@
<entry name='asset'>CZC1065993</entry>
<entry name='location'>Upside down</entry>
</baseBoard>
+ <oemStrings>
+ <entry>Hello</entry>
+ <entry>World</entry>
+ <entry>This is, more tricky value=escaped</entry>
+ </oemStrings>
</sysinfo>
<os>
<type arch='i686' machine='pc'>hvm</type>

View File

@ -1,3 +1,20 @@
-------------------------------------------------------------------
Fri Jan 26 15:44:30 UTC 2018 - jfehlig@suse.com
- qemu: Support setting OEM strings in SMBIOS
68eed56b-conf-smbios-oem-strings.patch,
76977061-qemu-smbios-oem-strings.patch
FATE#323624
- libxl: resume lock process after failed migration
0c710a37-libxl-resume-lock-on-mig-failure.patch
bsc#1076861
-------------------------------------------------------------------
Thu Jan 25 16:46:32 UTC 2018 - jfehlig@suse.com
- qemu hook: Change shebang to /usr/bin/python3
- spec: Require python lxml in daemon-hooks subpackage
-------------------------------------------------------------------
Fri Jan 19 16:31:53 UTC 2018 - jfehlig@suse.com

View File

@ -237,7 +237,6 @@ BuildRequires: libxslt
BuildRequires: ncurses-devel
BuildRequires: perl
BuildRequires: python
BuildRequires: python-xml
BuildRequires: readline-devel
# perl XPath is needed since we have a patch touching files that cause
# hvsupport.html to be regenerated
@ -320,6 +319,9 @@ Source100: %{name}-rpmlintrc
# Upstream patches
Patch0: 72adaf2f-revert-qemu-monitor-error-report.patch
Patch1: 71d56a39-nodedev-fix-parse-PCI-address.patch
Patch2: 68eed56b-conf-smbios-oem-strings.patch
Patch3: 76977061-qemu-smbios-oem-strings.patch
Patch4: 0c710a37-libxl-resume-lock-on-mig-failure.patch
# Patches pending upstream review
Patch100: libxl-dom-reset.patch
Patch101: network-don-t-use-dhcp-authoritative-on-static-netwo.patch
@ -416,6 +418,7 @@ Summary: Hook scripts for the libvirtd daemon
Group: Development/Libraries/C and C++
Requires: %{name}-daemon = %{version}-%{release}
Requires: python3-lxml
%description daemon-hooks
Default hook scripts for the libvirt daemon
@ -906,6 +909,9 @@ libvirt plugin for NSS for translating domain names into IP addresses.
%setup -q
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch100 -p1
%patch101 -p1
%patch150 -p1

View File

@ -262,7 +262,7 @@ Index: libvirt-4.0.0/src/libxl/libxl_migration.c
+ ret = libxlDoMigrateSend(driver, vm, props, sockfd);
virObjectLock(vm);
cleanup:
if (ret < 0)
Index: libvirt-4.0.0/src/libxl/libxl_migration.h
===================================================================
--- libvirt-4.0.0.orig/src/libxl/libxl_migration.h

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/python3
# libvirt hook script for QEMU/KVM domains. See the libvirt hooks
# documenation for more details
#