[libvirt] [PATCH] conf: Fix XML formatting of RNG device info
by Peter Krempa
https://bugzilla.redhat.com/show_bug.cgi?id=1035118
When outputting the XML for the RNG device, the code didn't format the
PCI address info. Additionally the schema wasn't expecting the info
although it was being parsed and used internally. Fix those mistakes and
add test for the PCI info section.
---
docs/schemas/domaincommon.rng | 6 ++++++
src/conf/domain_conf.c | 5 +++++
tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-default.args | 2 +-
tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-default.xml | 1 +
4 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 80848d2..38c6801 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3956,6 +3956,12 @@
<optional>
<ref name="rng-rate"/>
</optional>
+ <optional>
+ <ref name="alias"/>
+ </optional>
+ <optional>
+ <ref name="address"/>
+ </optional>
</interleave>
</element>
</define>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 65bd9b1..0268847 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -15832,6 +15832,11 @@ virDomainRNGDefFormat(virBufferPtr buf,
break;
}
+ if (virDomainDeviceInfoIsSet(&def->info, flags)) {
+ if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
+ return -1;
+ }
+
virBufferAddLit(buf, " </rng>\n");
return 0;
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-default.args b/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-default.args
index 01e9f89..4ae6257 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-default.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-default.args
@@ -4,4 +4,4 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \
-object rng-random,id=rng0 \
--device virtio-rng-pci,rng=rng0,bus=pci.0,addr=0x4
+-device virtio-rng-pci,rng=rng0,bus=pci.0,addr=0x7
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-default.xml b/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-default.xml
index 0852dea..0a7bf61 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-default.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-default.xml
@@ -18,6 +18,7 @@
<memballoon model='virtio'/>
<rng model='virtio'>
<backend model='random'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
</rng>
</devices>
</domain>
--
1.8.4.3
10 years, 11 months
[libvirt] [PATCH] qemu: snapshot: Fix incorrect disk type for auto-generated disks
by Peter Krempa
When changing the parsing and formatting functions in commit
43f2ccdc73090bd03f64de4d58d46ffa0134d705 I forgot to update the qemu
disk alingnment function for snapshots that automatically adds snapshot
configs for disks that were not mentioned in the XML. The function
allocated a new disk snapshot definition but did not correctly
initialize the snapshot disk source type variable. This resulted into
the disks considered as block devices and invalid XML was generated.
Reported by John Ferlan.
---
Notes:
Doing a unit test for this will require yet another addition to the testsuite
so I'm sending this patch first.
src/conf/snapshot_conf.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index 5637975..55abd80 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -532,6 +532,7 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def,
goto cleanup;
disk->index = i;
disk->snapshot = def->dom->disks[i]->snapshot;
+ disk->type = -1;
if (!disk->snapshot)
disk->snapshot = default_snapshot;
}
@@ -549,6 +550,15 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def,
const char *tmp;
struct stat sb;
+ if (disk->type != VIR_DOMAIN_DISK_TYPE_FILE ||
+ disk->type != -1) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("cannot generate external snapshot name "
+ "for disk '%s' on a '%s' device"),
+ disk->name, virDomainDiskTypeToString(disk->type));
+ goto cleanup;
+ }
+
if (!original) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("cannot generate external snapshot name "
--
1.8.4.3
10 years, 11 months
[libvirt] [PATCH v2 0/5] Support keyboard device
by Li Zhang
From: Li Zhang <zhlcindy(a)linux.vnet.ibm.com>
This patchset is to add keyboard input device.
For PPC64, it doesn't support a default keyboard device when the graphic
is enabled. Libvirt supports QEMU command line as "-device VGA" which
won't create any keyboard device for it. So it requires libvirt to add
a default USB keyboard device for it.
This patchset is to add keyboard input device and a default USB keyboard
for PPC64.
The related discussion in QEMU community:
http://lists.nongnu.org/archive/html/qemu-devel/2013-11/msg01734.html
Li Zhang (5):
conf: Add a keyboard input device type
qemu_cap: Add USB keyboard capability
docs/schemas/domaincommon.rng: add keyboard input device type
qemu: parse USB keyboard qemu command line.
Add a default USB keyboard for PPC64
v2 -> v1:
* change ifs to switch clause.
* reconstruct the patches
docs/schemas/domaincommon.rng | 1 +
src/conf/domain_conf.c | 62 ++++++++++++++++------
src/conf/domain_conf.h | 5 ++
src/libvirt_private.syms | 1 +
src/qemu/qemu_capabilities.c | 2 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 18 +++++--
src/qemu/qemu_domain.c | 14 ++++-
tests/qemucapabilitiesdata/caps_1.2.2-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.3.1-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.4.2-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.5.3-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.6.0-1.caps | 2 +
tests/qemucapabilitiesdata/caps_1.6.50-1.caps | 1 +
tests/qemuhelptest.c | 8 +++
.../qemuxml2argvdata/qemuxml2argv-pseries-disk.xml | 1 +
.../qemuxml2argv-pseries-usb-kbd.args | 9 ++++
.../qemuxml2argv-pseries-usb-kbd.xml | 19 +++++++
tests/qemuxml2argvtest.c | 3 ++
19 files changed, 130 insertions(+), 21 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.xml
--
1.8.2.1
10 years, 11 months
[libvirt] [PATCH 1/4] Add USB Keyboard support in libvirt
by Li Zhang
From: Li Zhang <zhlcindy(a)linux.vnet.ibm.com>
PS2 devices are not supported for non-x86 platforms. So it needs one USB
keyboard when graphic is enabled.
This patch is to add one kbd input device type for users to add one
USB keyboard in XML file as the following:
<input type='kbd' bus='usb'/>
Signed-off-by: Li Zhang <zhlcindy(a)linux.vnet.ibm.com>
---
src/conf/domain_conf.c | 3 ++-
src/conf/domain_conf.h | 1 +
src/qemu/qemu_capabilities.c | 3 +++
src/qemu/qemu_capabilities.h | 2 ++
src/qemu/qemu_command.c | 12 +++++++++---
5 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7b0e3ea..d90f05c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -504,7 +504,8 @@ VIR_ENUM_IMPL(virDomainVideo, VIR_DOMAIN_VIDEO_TYPE_LAST,
VIR_ENUM_IMPL(virDomainInput, VIR_DOMAIN_INPUT_TYPE_LAST,
"mouse",
- "tablet")
+ "tablet",
+ "kbd")
VIR_ENUM_IMPL(virDomainInputBus, VIR_DOMAIN_INPUT_BUS_LAST,
"ps2",
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 4561ccc..c8fecaf 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1222,6 +1222,7 @@ struct _virDomainTPMDef {
enum virDomainInputType {
VIR_DOMAIN_INPUT_TYPE_MOUSE,
VIR_DOMAIN_INPUT_TYPE_TABLET,
+ VIR_DOMAIN_INPUT_TYPE_KBD,
VIR_DOMAIN_INPUT_TYPE_LAST
};
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 548b988..89b11ad 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -243,6 +243,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
"virtio-mmio",
"ich9-intel-hda",
"kvm-pit-lost-tick-policy",
+
+ "usb-kbd", /*160*/
);
struct _virQEMUCaps {
@@ -1394,6 +1396,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
{ "usb-storage", QEMU_CAPS_DEVICE_USB_STORAGE },
{ "virtio-mmio", QEMU_CAPS_DEVICE_VIRTIO_MMIO },
{ "ich9-intel-hda", QEMU_CAPS_DEVICE_ICH9_INTEL_HDA },
+ { "usb-kbd", QEMU_CAPS_DEVICE_USB_KBD },
};
static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBlk[] = {
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 02d47c6..0b7b5e5 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -198,6 +198,8 @@ enum virQEMUCapsFlags {
QEMU_CAPS_DEVICE_VIRTIO_MMIO = 157, /* -device virtio-mmio */
QEMU_CAPS_DEVICE_ICH9_INTEL_HDA = 158, /* -device ich9-intel-hda */
QEMU_CAPS_KVM_PIT_TICK_POLICY = 159, /* kvm-pit.lost_tick_policy */
+ QEMU_CAPS_DEVICE_USB_KBD = 160, /*-device usb-kbd*/
+
QEMU_CAPS_LAST, /* this must always be the last item */
};
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 763417f..318f7a1 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -5280,9 +5280,15 @@ qemuBuildUSBInputDevStr(virDomainDefPtr def,
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
- virBufferAsprintf(&buf, "%s,id=%s",
- dev->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ?
- "usb-mouse" : "usb-tablet", dev->info.alias);
+ if (dev->type == VIR_DOMAIN_INPUT_TYPE_MOUSE) {
+ virBufferAsprintf(&buf, "usb-mouse,id=%s", dev->info.alias);
+ } else if (dev->type == VIR_DOMAIN_INPUT_TYPE_TABLET) {
+ virBufferAsprintf(&buf, "usb-tablet,id=%s", dev->info.alias);
+ } else if (dev->type == VIR_DOMAIN_INPUT_TYPE_KBD) {
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_USB_KBD))
+ goto error;
+ virBufferAsprintf(&buf, "usb-kbd,id=%s", dev->info.alias);
+ }
if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
goto error;
--
1.8.2.1
10 years, 11 months
[libvirt] [PATCH 0/3] add percentage limit support for RAM filesystems in LXC container
by Chen Hanxiao
From: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
Chen Hanxiao (3):
add percentage limit parse and define support for RAM filesystems
enable percentage limit of RAM filesystem in lxc container
docs: add docs for percentage limitation
docs/formatdomain.html.in | 4 +++-
src/conf/domain_conf.c | 21 +++++++++++++++++----
src/conf/domain_conf.h | 1 +
src/lxc/lxc_container.c | 14 +++++++++++---
4 files changed, 32 insertions(+), 8 deletions(-)
--
1.8.2.1
10 years, 11 months
[libvirt] Problems preserving lock state across suspend/resume
by Adam Tilghman
Hi folks,
I'm looking into a problem discussed back in January 2013
wherein lock/lease state isn't properly preserved across suspend/resume.
(This situation can lead to corruption if the guest's block storage is
modified elsewhere while the original guest is paused.)
For details see:
https://www.redhat.com/archives/libvirt-users/2013-January/msg00109.html
https://bugzilla.redhat.com/show_bug.cgi?id=906590
I'm using libvirt-1.2.0 with explicit Sanlock leases defined in the domain XML.
It appears the problematic behavior is due to virDomainLockProcessPause()
and virDomainLockProcessResume() being called twice during each
suspend/resume: once by the RPC worker thread running the suspend/resume
command, and once by the main thread in response to the QEMU events
triggered by the RPC worker's actions.
In libvirt-1.2.0, call paths for suspend are as follows:
qemuDomainObjBeginJob(suspend) ->
qemuDomainSuspend() ->
qemuProcessStopCPUs() ->
virDomainLockProcessPause()
qemuMonitorJSONIOProcessEvent:143 : handle STOP ->
qemuProcessHandleStop ->
virDomainLockProcessPause()
The first call -- usually out of qemuProcessHandleStop but perhaps
there's a race -- properly saves state and releases locks.
However the second call queries lock status after locks have been
released, so it finds no locks are held. This results in a null/blank
lockState saved in the domain object.
Before I start working on a solution, are these multiple invocations
of virDomainLockProcessPause()/virDomainLockProcessResume() intentional?
Thanks,
Adam Tilghman
UC San Diego
10 years, 11 months
[libvirt] [PATCH 1/2] qemu: hotplug: Mark 2 private functions as static
by Cole Robinson
They aren't used outside of qemu_hotplug.c
---
src/qemu/qemu_hotplug.c | 14 ++++++++------
src/qemu/qemu_hotplug.h | 6 ------
2 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index c136232..f4fc723 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1141,9 +1141,10 @@ try_remove:
}
-int qemuDomainAttachHostPciDevice(virQEMUDriverPtr driver,
- virDomainObjPtr vm,
- virDomainHostdevDefPtr hostdev)
+static int
+qemuDomainAttachHostPciDevice(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ virDomainHostdevDefPtr hostdev)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
int ret;
@@ -1433,9 +1434,10 @@ cleanup:
return ret;
}
-int qemuDomainAttachHostUsbDevice(virQEMUDriverPtr driver,
- virDomainObjPtr vm,
- virDomainHostdevDefPtr hostdev)
+static int
+qemuDomainAttachHostUsbDevice(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ virDomainHostdevDefPtr hostdev)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
virUSBDeviceList *list = NULL;
diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h
index 75789d6..ffc435c 100644
--- a/src/qemu/qemu_hotplug.h
+++ b/src/qemu/qemu_hotplug.h
@@ -47,12 +47,6 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
virQEMUDriverPtr driver,
virDomainObjPtr vm,
virDomainNetDefPtr net);
-int qemuDomainAttachHostPciDevice(virQEMUDriverPtr driver,
- virDomainObjPtr vm,
- virDomainHostdevDefPtr hostdev);
-int qemuDomainAttachHostUsbDevice(virQEMUDriverPtr driver,
- virDomainObjPtr vm,
- virDomainHostdevDefPtr hostdev);
int qemuDomainAttachRedirdevDevice(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virDomainRedirdevDefPtr hostdev);
--
1.8.4.2
10 years, 11 months
[libvirt] [PATCH] docs: fix double articles bug
by Wangyufei (A)
Delete the extra article 'the'.
Signed-off-by: Wang Yufei <james.wangyufei(a)huawei.com>
---
src/libvirt.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index eff44eb..0eb4c64 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -16525,7 +16525,7 @@ error:
* Otherwise, creates a new secret with an automatically chosen UUID, and
* initializes its attributes from xml.
*
- * Returns a the secret on success, NULL on failure.
+ * Returns a secret on success, NULL on failure.
*/
virSecretPtr
virSecretDefineXML(virConnectPtr conn, const char *xml, unsigned int flags)
--
1.7.3.1.msysgit.0
Best Regards,
-WangYufei
10 years, 11 months
[libvirt] [PATCH python v2] generator: Remove use of 'has_key' function
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
The code 'XXX.has_key(YYYY)' must be changed to be of
the form 'YYY in XXXX' which works in Python2 and 3
As an added complication, if 'YYY in XXX' is used against
an object overriding the '__getitem__' method it does not
work in Python 2.4. Instead we must use 'YYY in XXX.keys()'
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
generator.py | 108 +++++++++++++++++++++++++++++------------------------------
1 file changed, 54 insertions(+), 54 deletions(-)
diff --git a/generator.py b/generator.py
index 214abed..9053e91 100755
--- a/generator.py
+++ b/generator.py
@@ -76,11 +76,11 @@ class docParser(xml.sax.handler.ContentHandler):
self.function_return = None
self.function_file = None
self.function_module= None
- if attrs.has_key('name'):
+ if 'name' in attrs.keys():
self.function = attrs['name']
- if attrs.has_key('file'):
+ if 'file' in attrs.keys():
self.function_file = attrs['file']
- if attrs.has_key('module'):
+ if 'module' in attrs.keys():
self.function_module= attrs['module']
elif tag == 'cond':
self._data = []
@@ -91,24 +91,24 @@ class docParser(xml.sax.handler.ContentHandler):
self.function_arg_name = None
self.function_arg_type = None
self.function_arg_info = None
- if attrs.has_key('name'):
+ if 'name' in attrs.keys():
self.function_arg_name = attrs['name']
if self.function_arg_name == 'from':
self.function_arg_name = 'frm'
- if attrs.has_key('type'):
+ if 'type' in attrs.keys():
self.function_arg_type = attrs['type']
- if attrs.has_key('info'):
+ if 'info' in attrs.keys():
self.function_arg_info = attrs['info']
elif tag == 'return':
if self.in_function == 1:
self.function_return_type = None
self.function_return_info = None
self.function_return_field = None
- if attrs.has_key('type'):
+ if 'type' in attrs.keys():
self.function_return_type = attrs['type']
- if attrs.has_key('info'):
+ if 'info' in attrs.keys():
self.function_return_info = attrs['info']
- if attrs.has_key('field'):
+ if 'field' in attrs.keys():
self.function_return_field = attrs['field']
elif tag == 'enum':
# enums come from header files, hence virterror.h
@@ -207,7 +207,7 @@ def lxc_function(name, desc, ret, args, file, module, cond):
lxc_functions[name] = (desc, ret, args, file, module, cond)
def enum(type, name, value):
- if not enums.has_key(type):
+ if type not in enums:
enums[type] = {}
if value == 'VIR_TYPED_PARAM_INT':
value = 1
@@ -233,14 +233,14 @@ def enum(type, name, value):
enums[type][name] = value
def lxc_enum(type, name, value):
- if not lxc_enums.has_key(type):
+ if type not in lxc_enums:
lxc_enums[type] = {}
if onlyOverrides and name not in lxc_enums[type]:
return
lxc_enums[type][name] = value
def qemu_enum(type, name, value):
- if not qemu_enums.has_key(type):
+ if type not in qemu_enums:
qemu_enums[type] = {}
if onlyOverrides and name not in qemu_enums[type]:
return
@@ -603,7 +603,7 @@ def print_function_wrapper(module, name, output, export, include):
print("failed to get function %s infos" % name)
return
- if skipped_modules.has_key(module):
+ if module in skipped_modules:
return 0
if module == "libvirt":
@@ -637,7 +637,7 @@ def print_function_wrapper(module, name, output, export, include):
if arg[1][0:6] == "const ":
arg[1] = arg[1][6:]
c_args = c_args + " %s %s;\n" % (arg[1], arg[0])
- if py_types.has_key(arg[1]):
+ if arg[1] in py_types:
(f, t, n, c) = py_types[arg[1]]
if (f == 'z') and (name in foreign_encoding_args) and (num_bufs == 0):
f = 't#'
@@ -659,9 +659,9 @@ def print_function_wrapper(module, name, output, export, include):
c_call = c_call + ", "
c_call = c_call + "%s" % (arg[0])
else:
- if skipped_types.has_key(arg[1]):
+ if arg[1] in skipped_types:
return 0
- if unknown_types.has_key(arg[1]):
+ if arg[1] in unknown_types:
lst = unknown_types[arg[1]]
lst.append(name)
else:
@@ -683,7 +683,7 @@ def print_function_wrapper(module, name, output, export, include):
else:
c_call = "\n %s(%s);\n" % (name, c_call)
ret_convert = " Py_INCREF(Py_None);\n return Py_None;\n"
- elif py_types.has_key(ret[0]):
+ elif ret[0] in py_types:
(f, t, n, c) = py_types[ret[0]]
c_return = " %s c_retval;\n" % (ret[0])
if file == "python_accessor" and ret[2] is not None:
@@ -692,16 +692,16 @@ def print_function_wrapper(module, name, output, export, include):
c_call = "\n c_retval = %s(%s);\n" % (name, c_call)
ret_convert = " py_retval = libvirt_%sWrap((%s) c_retval);\n" % (n,c)
ret_convert = ret_convert + " return py_retval;\n"
- elif py_return_types.has_key(ret[0]):
+ elif ret[0] in py_return_types:
(f, t, n, c) = py_return_types[ret[0]]
c_return = " %s c_retval;\n" % (ret[0])
c_call = "\n c_retval = %s(%s);\n" % (name, c_call)
ret_convert = " py_retval = libvirt_%sWrap((%s) c_retval);\n" % (n,c)
ret_convert = ret_convert + " return py_retval;\n"
else:
- if skipped_types.has_key(ret[0]):
+ if ret[0] in skipped_types:
return 0
- if unknown_types.has_key(ret[0]):
+ if ret[0] in unknown_types:
lst = unknown_types[ret[0]]
lst.append(name)
else:
@@ -1254,10 +1254,10 @@ def buildWrappers(module):
ctypes.append(type)
ctypes_processed[type] = ()
for type in list(classes_type.keys()):
- if ctypes_processed.has_key(type):
+ if type in ctypes_processed:
continue
tinfo = classes_type[type]
- if not classes_processed.has_key(tinfo[2]):
+ if tinfo[2] not in classes_processed:
classes_list.append(tinfo[2])
classes_processed[tinfo[2]] = ()
@@ -1319,7 +1319,7 @@ def buildWrappers(module):
if extra is not None:
extra.close()
- if function_classes.has_key("None"):
+ if "None" in function_classes:
flist = function_classes["None"]
flist.sort(functionCompare)
oldfile = ""
@@ -1344,7 +1344,7 @@ def buildWrappers(module):
writeDoc(module, name, args, ' ', classes)
for arg in args:
- if classes_type.has_key(arg[1]):
+ if arg[1] in classes_type:
classes.write(" if %s is None: %s__o = None\n" %
(arg[0], arg[0]))
classes.write(" else: %s__o = %s%s\n" %
@@ -1359,17 +1359,17 @@ def buildWrappers(module):
if n != 0:
classes.write(", ")
classes.write("%s" % arg[0])
- if classes_type.has_key(arg[1]):
+ if arg[1] in classes_type:
classes.write("__o")
n = n + 1
classes.write(")\n")
if ret[0] != "void":
- if classes_type.has_key(ret[0]):
+ if ret[0] in classes_type:
#
# Raise an exception
#
- if functions_noexcept.has_key(name):
+ if name in functions_noexcept:
classes.write(" if ret is None:return None\n")
else:
classes.write(
@@ -1384,8 +1384,8 @@ def buildWrappers(module):
# several things that we can do, depending on the
# contents of functions_int_*:
elif is_integral_type (ret[0]):
- if not functions_noexcept.has_key (name):
- if functions_int_exception_test.has_key (name):
+ if name not in functions_noexcept:
+ if name in functions_int_exception_test:
test = functions_int_exception_test[name]
else:
test = functions_int_default_test
@@ -1395,8 +1395,8 @@ def buildWrappers(module):
classes.write(" return ret\n")
elif is_python_noninteger_type (ret[0]):
- if not functions_noexcept.has_key (name):
- if functions_list_exception_test.has_key (name):
+ if name not in functions_noexcept:
+ if name in functions_list_exception_test:
test = functions_list_exception_test[name]
else:
test = functions_list_default_test
@@ -1414,11 +1414,11 @@ def buildWrappers(module):
if classname == "None":
pass
else:
- if classes_ancestor.has_key(classname):
+ if classname in classes_ancestor:
classes.write("class %s(%s):\n" % (classname,
classes_ancestor[classname]))
classes.write(" def __init__(self, _obj=None):\n")
- if reference_keepers.has_key(classname):
+ if classname in reference_keepers:
rlist = reference_keepers[classname]
for ref in rlist:
classes.write(" self.%s = None\n" % ref[1])
@@ -1435,7 +1435,7 @@ def buildWrappers(module):
classes.write(" def __init__(self, dom, _obj=None):\n")
else:
classes.write(" def __init__(self, _obj=None):\n")
- if reference_keepers.has_key(classname):
+ if classname in reference_keepers:
rlist = reference_keepers[classname]
for ref in rlist:
classes.write(" self.%s = None\n" % ref[1])
@@ -1452,7 +1452,7 @@ def buildWrappers(module):
classes.write(" self._conn = dom.connect()\n")
classes.write(" self._o = _obj\n\n")
destruct=None
- if classes_destructors.has_key(classname):
+ if classname in classes_destructors:
classes.write(" def __del__(self):\n")
classes.write(" if self._o is not None:\n")
classes.write(" libvirtmod.%s(self._o)\n" %
@@ -1460,12 +1460,12 @@ def buildWrappers(module):
classes.write(" self._o = None\n\n")
destruct=classes_destructors[classname]
- if not class_skip_connect_impl.has_key(classname):
+ if classname not in class_skip_connect_impl:
# Build python safe 'connect' method
classes.write(" def connect(self):\n")
classes.write(" return self._conn\n\n")
- if class_domain_impl.has_key(classname):
+ if classname in class_domain_impl:
classes.write(" def domain(self):\n")
classes.write(" return self._dom\n\n")
@@ -1504,7 +1504,7 @@ def buildWrappers(module):
writeDoc(module, name, args, ' ', classes)
n = 0
for arg in args:
- if classes_type.has_key(arg[1]):
+ if arg[1] in classes_type:
if n != index:
classes.write(" if %s is None: %s__o = None\n" %
(arg[0], arg[0]))
@@ -1522,11 +1522,11 @@ def buildWrappers(module):
classes.write(", ")
if n != index:
classes.write("%s" % arg[0])
- if classes_type.has_key(arg[1]):
+ if arg[1] in classes_type:
classes.write("__o")
else:
classes.write("self")
- if classes_type.has_key(arg[1]):
+ if arg[1] in classes_type:
classes.write(classes_type[arg[1]][0])
n = n + 1
classes.write(")\n")
@@ -1536,11 +1536,11 @@ def buildWrappers(module):
# For functions returning object types:
if ret[0] != "void":
- if classes_type.has_key(ret[0]):
+ if ret[0] in classes_type:
#
# Raise an exception
#
- if functions_noexcept.has_key(name):
+ if name in functions_noexcept:
classes.write(
" if ret is None:return None\n")
else:
@@ -1590,7 +1590,7 @@ def buildWrappers(module):
# See reference_keepers for the list
#
tclass = classes_type[ret[0]][2]
- if reference_keepers.has_key(tclass):
+ if tclass in reference_keepers:
rlist = reference_keepers[tclass]
for pref in rlist:
if pref[0] == classname:
@@ -1598,7 +1598,7 @@ def buildWrappers(module):
pref[1])
# Post-processing - just before we return.
- if function_post.has_key(name):
+ if name in function_post:
classes.write(" %s\n" %
(function_post[name]))
@@ -1606,16 +1606,16 @@ def buildWrappers(module):
# return the class
#
classes.write(" return __tmp\n")
- elif converter_type.has_key(ret[0]):
+ elif ret[0] in converter_type:
#
# Raise an exception
#
- if functions_noexcept.has_key(name):
+ if name in functions_noexcept:
classes.write(
" if ret is None:return None")
# Post-processing - just before we return.
- if function_post.has_key(name):
+ if name in function_post:
classes.write(" %s\n" %
(function_post[name]))
@@ -1627,8 +1627,8 @@ def buildWrappers(module):
# are several things that we can do, depending on
# the contents of functions_int_*:
elif is_integral_type (ret[0]):
- if not functions_noexcept.has_key (name):
- if functions_int_exception_test.has_key (name):
+ if name not in functions_noexcept:
+ if name in functions_int_exception_test:
test = functions_int_exception_test[name]
else:
test = functions_int_default_test
@@ -1662,15 +1662,15 @@ def buildWrappers(module):
("ret", name))
# Post-processing - just before we return.
- if function_post.has_key(name):
+ if name in function_post:
classes.write(" %s\n" %
(function_post[name]))
classes.write (" return ret\n")
elif is_python_noninteger_type (ret[0]):
- if not functions_noexcept.has_key (name):
- if functions_list_exception_test.has_key (name):
+ if name not in functions_noexcept:
+ if name in functions_list_exception_test:
test = functions_list_exception_test[name]
else:
test = functions_list_default_test
@@ -1704,7 +1704,7 @@ def buildWrappers(module):
("ret", name))
# Post-processing - just before we return.
- if function_post.has_key(name):
+ if name in function_post:
classes.write(" %s\n" %
(function_post[name]))
@@ -1712,7 +1712,7 @@ def buildWrappers(module):
else:
# Post-processing - just before we return.
- if function_post.has_key(name):
+ if name in function_post:
classes.write(" %s\n" %
(function_post[name]))
--
1.8.3.1
10 years, 11 months
[libvirt] [PATCH V2] AArch64: Porting of armv7l conditons to run qemu for aarch64.
by Pranavkumar Sawargaonkar
AArch64 qemu has similar behavior as armv7l, like use of mmio etc.
This patch adds similar bypass checks what we have for armv7l to aarch64.
E.g. we are enabling mmio transport for Nicdev.
Making addDefaultUSB and addDefaultMemballoon to false etc.
This patch also adds testcase to qemuxml2argvtest as suggested
during review comments of V1 of same patch.
Signed-off-by: Anup Patel <anup.patel(a)linaro.org>
Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar(a)linaro.org>
---
src/qemu/qemu_capabilities.c | 2 +-
src/qemu/qemu_command.c | 8 ++--
src/qemu/qemu_domain.c | 4 ++
.../qemuxml2argv-aarch64-virt-virtio.args | 14 ++++++
.../qemuxml2argv-aarch64-virt-virtio.xml | 45 ++++++++++++++++++++
tests/qemuxml2argvtest.c | 4 ++
6 files changed, 73 insertions(+), 4 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.xml
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index a68e555..9df3292 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2889,7 +2889,7 @@ virQEMUCapsSupportsChardev(virDomainDefPtr def,
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE))
return false;
- if (def->os.arch != VIR_ARCH_ARMV7L)
+ if ((def->os.arch != VIR_ARCH_ARMV7L) && (def->os.arch != VIR_ARCH_AARCH64))
return true;
/* This may not be true for all ARM machine types, but at least
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 9539be7..62a16a2 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -427,7 +427,8 @@ qemuDomainSupportsNicdev(virDomainDefPtr def,
return false;
/* non-virtio ARM nics require legacy -net nic */
- if (def->os.arch == VIR_ARCH_ARMV7L &&
+ if (((def->os.arch == VIR_ARCH_ARMV7L) ||
+ (def->os.arch == VIR_ARCH_AARCH64)) &&
net->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO)
return false;
@@ -1340,7 +1341,8 @@ static int
qemuDomainAssignARMVirtioMMIOAddresses(virDomainDefPtr def,
virQEMUCapsPtr qemuCaps)
{
- if (def->os.arch == VIR_ARCH_ARMV7L &&
+ if (((def->os.arch == VIR_ARCH_ARMV7L) ||
+ (def->os.arch == VIR_ARCH_AARCH64)) &&
(STRPREFIX(def->os.machine, "vexpress-") ||
STREQ(def->os.machine, "virt")) &&
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_MMIO)) {
@@ -1872,7 +1874,7 @@ cleanup:
static bool
qemuDomainSupportsPCI(virDomainDefPtr def) {
- if (def->os.arch != VIR_ARCH_ARMV7L)
+ if ((def->os.arch != VIR_ARCH_ARMV7L) && (def->os.arch != VIR_ARCH_AARCH64))
return true;
if (STREQ(def->os.machine, "versatilepb"))
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 346fec3..529b367 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -727,6 +727,10 @@ qemuDomainDefPostParse(virDomainDefPtr def,
addDefaultUSB = false;
addDefaultMemballoon = false;
break;
+ case VIR_ARCH_AARCH64:
+ addDefaultUSB = false;
+ addDefaultMemballoon = false;
+ break;
case VIR_ARCH_ALPHA:
case VIR_ARCH_PPC:
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.args
new file mode 100644
index 0000000..afd6e41
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.args
@@ -0,0 +1,14 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-aarch64 -S -M virt -m 1024 -smp 1 -nographic \
+-nodefconfig -nodefaults -monitor unix:/tmp/test-monitor,server,nowait \
+-boot c -kernel /aarch64.kernel -initrd /aarch64.initrd -append \
+'earlyprintk console=ttyAMA0,115200n8 rw root=/dev/vda rootwait' \
+-dtb /aarch64.dtb -device virtio-serial-device,id=virtio-serial0 -usb \
+-drive file=/aarch64.raw,if=none,id=drive-virtio-disk0 \
+-device virtio-blk-device,drive=drive-virtio-disk0,id=virtio-disk0 \
+-device virtio-net-device,vlan=0,id=net0,mac=52:54:00:09:a4:37 \
+-net user,vlan=0,name=hostnet0 -serial pty -chardev pty,id=charconsole1 \
+-device virtconsole,chardev=charconsole1,id=console1 \
+-device virtio-balloon-device,id=balloon0 \
+-object rng-random,id=rng0,filename=/dev/random \
+-device virtio-rng-device,rng=rng0
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.xml
new file mode 100644
index 0000000..184b62c
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.xml
@@ -0,0 +1,45 @@
+<domain type="qemu">
+ <name>aarch64test</name>
+ <uuid>496d7ea8-9739-544b-4ebd-ef08be936e8b</uuid>
+ <memory>1048576</memory>
+ <currentMemory>1048576</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch="aarch64" machine="virt">hvm</type>
+ <kernel>/aarch64.kernel</kernel>
+ <initrd>/aarch64.initrd</initrd>
+ <dtb>/aarch64.dtb</dtb>
+ <cmdline>earlyprintk console=ttyAMA0,115200n8 rw root=/dev/vda rootwait</cmdline>
+ </os>
+ <features>
+ <acpi/>
+ <apic/>
+ <pae/>
+ </features>
+ <clock offset="utc"/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>restart</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-aarch64</emulator>
+ <disk type='file' device='disk'>
+ <source file='/aarch64.raw'/>
+ <target dev='vda' bus='virtio'/>
+ </disk>
+ <interface type='user'>
+ <mac address='52:54:00:09:a4:37'/>
+ <model type='virtio'/>
+ </interface>
+ <console type='pty'/>
+ <console type='pty'>
+ <target type='virtio' port='0'/>
+ </console>
+ <memballoon model='virtio'/>
+ <!--
+ This actually doesn't work in practice because vexpress only has
+ 4 virtio slots available, rng makes 5 -->
+ <rng model='virtio'>
+ <backend model='random'>/dev/random</backend>
+ </rng>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index f9abf1b..1aec0c4 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1299,6 +1299,10 @@ mymain(void)
QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB,
QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE_VIRTIO_MMIO,
QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
+ DO_TEST("aarch64-virt-virtio",
+ QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB,
+ QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE_VIRTIO_MMIO,
+ QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
DO_TEST("kvm-pit-device", QEMU_CAPS_KVM_PIT_TICK_POLICY);
DO_TEST("kvm-pit-delay", QEMU_CAPS_NO_KVM_PIT);
--
1.7.9.5
10 years, 11 months