[libvirt] [PATCH 5/5] S390: Adding testcases for s390
by Viktor Mihajlovski
Add minimal s390-virtio domain testcase and testcases for virtio serial,
net, disk for the virtio-s390 bus.
Signed-off-by: Viktor Mihajlovski <mihajlov(a)linux.vnet.ibm.com>
---
.../qemuxml2argv-console-virtio-s390.args | 9 ++++++
.../qemuxml2argv-console-virtio-s390.xml | 24 +++++++++++++++
.../qemuxml2argv-disk-virtio-s390.args | 5 +++
.../qemuxml2argv-disk-virtio-s390.xml | 22 ++++++++++++++
.../qemuxml2argv-minimal-s390.args | 5 +++
.../qemuxml2argvdata/qemuxml2argv-minimal-s390.xml | 21 +++++++++++++
.../qemuxml2argv-net-virtio-s390.args | 5 +++
.../qemuxml2argv-net-virtio-s390.xml | 22 ++++++++++++++
tests/qemuxml2argvtest.c | 8 +++++
tests/testutilsqemu.c | 31 ++++++++++++++++++++
10 files changed, 152 insertions(+), 0 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-console-virtio-s390.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-console-virtio-s390.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-s390.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-s390.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-minimal-s390.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-minimal-s390.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-virtio-s390.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-virtio-s390.xml
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-s390.args b/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-s390.args
new file mode 100644
index 0000000..3388a35
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-s390.args
@@ -0,0 +1,9 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
+s390-virtio -m 214 -smp 1 -nographic -nodefconfig -nodefaults -chardev \
+socket,id=charmonitor,path=/tmp/test-monitor,server,nowait -mon \
+chardev=charmonitor,id=monitor,mode=readline -no-acpi \
+-boot c -device virtio-serial-s390,id=virtio-serial0 \
+-drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-virtio-disk0 \
+-device virtio-blk-s390,drive=drive-virtio-disk0,id=virtio-disk0 \
+-chardev pty,id=charconsole0 \
+-device virtconsole,chardev=charconsole0,id=console0 -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-s390.xml b/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-s390.xml
new file mode 100644
index 0000000..5a4a9d4
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-s390.xml
@@ -0,0 +1,24 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219100</memory>
+ <currentMemory>219100</currentMemory>
+ <os>
+ <type arch='s390x' machine='s390-virtio'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='virtio'/>
+ </disk>
+ <console type='pty'>
+ <target type='virtio'/>
+ </console>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-s390.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-s390.args
new file mode 100644
index 0000000..66bdf1e
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-s390.args
@@ -0,0 +1,5 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S \
+-M s390-virtio -m 214 -smp 1 -nographic -nodefaults \
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \
+-drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-virtio-disk0 \
+-device virtio-blk-s390,drive=drive-virtio-disk0,id=virtio-disk0 -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-s390.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-s390.xml
new file mode 100644
index 0000000..9ce6c18
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-s390.xml
@@ -0,0 +1,22 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219136</memory>
+ <currentMemory>219136</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='s390x' machine='s390-virtio'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='virtio'/>
+ </disk>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-minimal-s390.args b/tests/qemuxml2argvdata/qemuxml2argv-minimal-s390.args
new file mode 100644
index 0000000..4e7bf05
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-minimal-s390.args
@@ -0,0 +1,5 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu \
+-name QEMUGuest1 -S -M s390-virtio -m 214 -smp 1 -nographic \
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi \
+-boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial \
+none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-minimal-s390.xml b/tests/qemuxml2argvdata/qemuxml2argv-minimal-s390.xml
new file mode 100644
index 0000000..7378bd4
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-minimal-s390.xml
@@ -0,0 +1,21 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219100</memory>
+ <currentMemory>219100</currentMemory>
+ <os>
+ <type arch='s390x' machine='s390-virtio'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='virtio'/>
+ </disk>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-s390.args b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-s390.args
new file mode 100644
index 0000000..700ea84
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-s390.args
@@ -0,0 +1,5 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S \
+-M s390-virtio -m 214 -smp 1 -nographic -nodefaults \
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \
+-device virtio-net-s390,vlan=0,id=net0,mac=00:11:22:33:44:55 \
+-net user,vlan=0,name=hostnet0 -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-s390.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-s390.xml
new file mode 100644
index 0000000..f42fadd
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-s390.xml
@@ -0,0 +1,22 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219136</memory>
+ <currentMemory>219136</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='s390x' machine='s390-virtio'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <interface type='user'>
+ <mac address='00:11:22:33:44:55'/>
+ <model type='virtio'/>
+ </interface>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 3b339be..8cd8a91 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -341,6 +341,7 @@ mymain(void)
unsetenv("SDL_AUDIODRIVER");
DO_TEST("minimal", false, QEMU_CAPS_NAME);
+ DO_TEST("minimal-s390", false, QEMU_CAPS_NAME);
DO_TEST("machine-aliases1", false, NONE);
DO_TEST("machine-aliases2", true, NONE);
DO_TEST("boot-cdrom", false, NONE);
@@ -393,6 +394,8 @@ mymain(void)
QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE);
DO_TEST("disk-many", false, NONE);
DO_TEST("disk-virtio", false, QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_BOOT);
+ DO_TEST("disk-virtio-s390", false, QEMU_CAPS_DRIVE,
+ QEMU_CAPS_DEVICE, QEMU_CAPS_VIRTIO_S390);
DO_TEST("disk-order", false,
QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE_BOOT,
QEMU_CAPS_VIRTIO_BLK_SCSI, QEMU_CAPS_VIRTIO_BLK_SG_IO);
@@ -552,6 +555,8 @@ mymain(void)
QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_VIRTIO_TX_ALG);
DO_TEST("net-virtio-netdev", false,
QEMU_CAPS_DEVICE, QEMU_CAPS_NETDEV, QEMU_CAPS_NODEFCONFIG);
+ DO_TEST("net-virtio-s390", false,
+ QEMU_CAPS_DEVICE, QEMU_CAPS_VIRTIO_S390);
DO_TEST("net-eth", false, NONE);
DO_TEST("net-eth-ifname", false, NONE);
DO_TEST("net-eth-names", false, QEMU_CAPS_NET_NAME);
@@ -609,6 +614,9 @@ mymain(void)
QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
DO_TEST("console-virtio-many", false,
QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
+ DO_TEST("console-virtio-s390", false,
+ QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
+ QEMU_CAPS_DRIVE, QEMU_CAPS_VIRTIO_S390);
DO_TEST("channel-spicevmc", false,
QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
QEMU_CAPS_SPICE, QEMU_CAPS_CHARDEV_SPICEVMC);
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index 8d5a3bf..74b9122 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -87,6 +87,34 @@ error:
return -1;
}
+static int testQemuAddS390Guest(virCapsPtr caps)
+{
+ static const char *s390_machines[] = { "s390-virtio"};
+ virCapsGuestMachinePtr *machines = NULL;
+ virCapsGuestPtr guest;
+
+ machines = virCapabilitiesAllocMachines(s390_machines,
+ ARRAY_CARDINALITY(s390_machines));
+ if (!machines)
+ goto error;
+
+ guest = virCapabilitiesAddGuest(caps, "hvm", "s390x", 64,
+ "/usr/bin/qemu-system-s390x", NULL,
+ ARRAY_CARDINALITY(s390_machines),
+ machines);
+ if (!guest)
+ goto error;
+
+ if (!virCapabilitiesAddGuestDomain(guest, "qemu", NULL, NULL, 0, NULL))
+ goto error;
+
+ return 0;
+
+error:
+ virCapabilitiesFreeMachines(machines, ARRAY_CARDINALITY(s390_machines));
+ return -1;
+}
+
virCapsPtr testQemuCapsInit(void) {
virCapsPtr caps;
virCapsGuestPtr guest;
@@ -208,6 +236,9 @@ virCapsPtr testQemuCapsInit(void) {
if (testQemuAddPPC64Guest(caps))
goto cleanup;
+ if (testQemuAddS390Guest(caps))
+ goto cleanup;
+
if (virTestGetDebug()) {
char *caps_str;
--
1.7.0.4
--
Mit freundlichen Grüßen/Kind Regards
Viktor Mihajlovski
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
12 years, 5 months
[libvirt] [PATCH 4/5] S390: Domain Schema for s390-virtio machines.
by Viktor Mihajlovski
Added s390-virtio machine type to the XML schema for domains in order
to not fail the domain schema tests.
Signed-off-by: Viktor Mihajlovski <mihajlov(a)linux.vnet.ibm.com>
---
docs/schemas/domaincommon.rng | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 46e539d..a80f8b9 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -283,6 +283,7 @@
<ref name="hvmsparc"/>
<ref name="hvmppc"/>
<ref name="hvmppc64"/>
+ <ref name="hvms390"/>
</choice>
</optional>
<value>hvm</value>
@@ -369,6 +370,25 @@
</optional>
</group>
</define>
+ <define name="hvms390">
+ <group>
+ <optional>
+ <attribute name="arch">
+ <choice>
+ <value>s390</value>
+ <value>s390x</value>
+ </choice>
+ </attribute>
+ </optional>
+ <optional>
+ <attribute name="machine">
+ <choice>
+ <value>s390-virtio</value>
+ </choice>
+ </attribute>
+ </optional>
+ </group>
+ </define>
<define name="osexe">
<element name="os">
<element name="type">
--
1.7.0.4
--
Mit freundlichen Grüßen/Kind Regards
Viktor Mihajlovski
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
12 years, 5 months
[libvirt] [PATCH 3/5] S390: Add support for virtio-s390 devices.
by Viktor Mihajlovski
The s390(x) architecture doesn't feature a PCI bus. For the purpose of
supporting virtio devices a virtual bus called virtio-s390 is used.
A new address type VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390 is used to
distinguish the virtio devices on s390 from PCI-based virtio devices.
Signed-off-by: Viktor Mihajlovski <mihajlov(a)linux.vnet.ibm.com>
---
src/conf/domain_conf.c | 11 +++-
src/conf/domain_conf.h | 1 +
src/qemu/qemu_capabilities.c | 7 +++
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 98 +++++++++++++++++++++++++++++++++++++++--
5 files changed, 110 insertions(+), 8 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 81c6308..4db771e 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -150,7 +150,8 @@ VIR_ENUM_IMPL(virDomainDeviceAddress, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST,
"virtio-serial",
"ccid",
"usb",
- "spapr-vio")
+ "spapr-vio",
+ "virtio-s390")
VIR_ENUM_IMPL(virDomainDeviceAddressPciMulti,
VIR_DOMAIN_DEVICE_ADDRESS_PCI_MULTI_LAST,
@@ -2130,7 +2131,8 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
virBufferAddLit(buf, "/>\n");
}
- if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
+ if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE ||
+ info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390)
return 0;
/* We'll be in domain/devices/[device type]/ so 3 level indent */
@@ -4121,6 +4123,7 @@ virDomainControllerDefParseXML(xmlNodePtr node,
if (def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO &&
+ def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390 &&
def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Controllers must use the 'pci' address type"));
@@ -4646,6 +4649,7 @@ virDomainNetDefParseXML(virCapsPtr caps,
* them we should make sure address type is correct */
if (def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO &&
+ def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390 &&
def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Network interfaces must use 'pci' address type"));
@@ -9048,7 +9052,8 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
def->memballoon = memballoon;
VIR_FREE(nodes);
- } else {
+ } else if (!STREQ(def->os.arch,"s390x")) {
+ /* TODO: currently no balloon support on s390 -> no default balloon */
if (def->virtType == VIR_DOMAIN_VIRT_XEN ||
def->virtType == VIR_DOMAIN_VIRT_QEMU ||
def->virtType == VIR_DOMAIN_VIRT_KQEMU ||
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 44280ba..0b54646 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -172,6 +172,7 @@ enum virDomainDeviceAddressType {
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID,
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB,
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO,
+ VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390,
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST
};
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 0c01cb0..9e8bded 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -165,6 +165,7 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST,
"hda-micro", /* 95 */
"dump-guest-memory",
+ "virtio-s390",
);
@@ -1427,6 +1428,12 @@ qemuCapsParseDeviceStr(const char *str, virBitmapPtr flags)
qemuCapsSet(flags, QEMU_CAPS_USB_HUB);
if (strstr(str, "name \"ich9-ahci\""))
qemuCapsSet(flags, QEMU_CAPS_ICH9_AHCI);
+ if (strstr(str, "name \"virtio-blk-s390\""))
+ qemuCapsSet(flags, QEMU_CAPS_VIRTIO_S390);
+ if (strstr(str, "name \"virtio-net-s390\""))
+ qemuCapsSet(flags, QEMU_CAPS_VIRTIO_S390);
+ if (strstr(str, "name \"virtio-serial-s390\""))
+ qemuCapsSet(flags, QEMU_CAPS_VIRTIO_S390);
/* Prefer -chardev spicevmc (detected earlier) over -device spicevmc */
if (!qemuCapsGet(flags, QEMU_CAPS_CHARDEV_SPICEVMC) &&
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 640f7f5..c117a39 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -132,6 +132,7 @@ enum qemuCapsFlags {
QEMU_CAPS_NO_USER_CONFIG = 94, /* -no-user-config */
QEMU_CAPS_HDA_MICRO = 95, /* -device hda-micro */
QEMU_CAPS_DUMP_GUEST_MEMORY = 96, /* dump-guest-memory command */
+ QEMU_CAPS_VIRTIO_S390 = 97, /* -device virtio-*-s390 */
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 bee48e1..8b14d10 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -734,6 +734,67 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virBitmapPtr qemuCaps)
return -1;
}
+static void
+qemuDomainPrimeS390VirtioDevices(virDomainDefPtr def,
+ enum virDomainDeviceAddressType type)
+{
+ /*
+ declare address-less virtio devices to be of address type 'type'
+ only disks, networks, consoles and controllers for now
+ */
+ int i;
+
+ for (i = 0; i < def->ndisks ; i++) {
+ if (def->disks[i]->bus == VIR_DOMAIN_DISK_BUS_VIRTIO &&
+ def->disks[i]->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
+ def->disks[i]->info.type = type;
+ }
+
+ for (i = 0; i < def->nnets ; i++) {
+ if (STREQ(def->nets[i]->model,"virtio") &&
+ def->nets[i]->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
+ def->nets[i]->info.type = type;
+ }
+
+ for (i = 0; i < def->ncontrollers ; i++) {
+ if (def->controllers[i]->type ==
+ VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL &&
+ def->controllers[i]->info.type ==
+ VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
+ def->controllers[i]->info.type = type;
+ }
+
+}
+
+static int
+qemuDomainAssignS390Addresses(virDomainDefPtr def, virBitmapPtr qemuCaps)
+{
+ int ret = -1;
+ virBitmapPtr localCaps = NULL;
+
+ if (!qemuCaps) {
+ /* need to get information from real environment */
+ if (qemuCapsExtractVersionInfo(def->emulator, def->os.arch,
+ NULL,
+ &localCaps) < 0)
+ goto cleanup;
+ qemuCaps = localCaps;
+ }
+
+ if (qemuCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_S390)) {
+ /* deal with legacy virtio-s390 */
+ qemuDomainPrimeS390VirtioDevices(
+ def, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390);
+ }
+
+ ret = 0;
+
+cleanup:
+ qemuCapsFree(localCaps);
+
+ return ret;
+}
+
static int
qemuSpaprVIOFindByReg(virDomainDefPtr def ATTRIBUTE_UNUSED,
virDomainDeviceDefPtr device ATTRIBUTE_UNUSED,
@@ -1001,6 +1062,10 @@ int qemuDomainAssignAddresses(virDomainDefPtr def, virBitmapPtr qemuCaps,
if (rc)
return rc;
+ rc = qemuDomainAssignS390Addresses(def, qemuCaps);
+ if (rc)
+ return rc;
+
return qemuDomainAssignPCIAddresses(def, qemuCaps, obj);
}
@@ -1545,7 +1610,10 @@ qemuAssignDevicePCISlots(virDomainDefPtr def, qemuDomainPCIAddressSetPtr addrs)
if (def->disks[i]->bus != VIR_DOMAIN_DISK_BUS_VIRTIO)
continue;
- if (def->disks[i]->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)
+ /* don't touch s390 devices */
+ if (def->disks[i]->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI ||
+ def->disks[i]->info.type ==
+ VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390)
continue;
if (def->disks[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
@@ -2020,7 +2088,13 @@ qemuBuildDriveStr(virConnectPtr conn ATTRIBUTE_UNUSED,
break;
case VIR_DOMAIN_DISK_BUS_VIRTIO:
- /* Each virtio drive is a separate PCI device, no unit/busid or index */
+ if (qemuCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_S390) &&
+ (disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390)) {
+ /* Paranoia - leave in here for now */
+ qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("unexpected address type for s390-virtio disk"));
+ goto error;
+ }
idx = -1;
break;
@@ -2450,7 +2524,12 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
disk->info.addr.drive.unit);
break;
case VIR_DOMAIN_DISK_BUS_VIRTIO:
- virBufferAddLit(&opt, "virtio-blk-pci");
+ if (disk->info.type ==
+ VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390) {
+ virBufferAddLit(&opt, "virtio-blk-s390");
+ } else {
+ virBufferAddLit(&opt, "virtio-blk-pci");
+ }
qemuBuildIoEventFdStr(&opt, disk->ioeventfd, qemuCaps);
if (disk->event_idx &&
qemuCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_BLK_EVENT_IDX)) {
@@ -2706,6 +2785,9 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef,
case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL:
if (def->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
virBufferAddLit(&buf, "virtio-serial-pci");
+ } else if (def->info.type ==
+ VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390) {
+ virBufferAddLit(&buf, "virtio-serial-s390");
} else {
virBufferAddLit(&buf, "virtio-serial");
}
@@ -2801,7 +2883,12 @@ qemuBuildNicDevStr(virDomainNetDefPtr net,
if (!net->model) {
nic = "rtl8139";
} else if (STREQ(net->model, "virtio")) {
- nic = "virtio-net-pci";
+ if (net->info.type ==
+ VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390) {
+ nic = "virtio-net-s390";
+ } else {
+ nic = "virtio-net-pci";
+ }
usingVirtio = true;
} else {
nic = net->model;
@@ -3604,7 +3691,8 @@ qemuBuildVirtioSerialPortDevStr(virDomainChrDefPtr dev,
return NULL;
}
- if (dev->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
+ if (dev->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
+ dev->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390) {
/* Check it's a virtio-serial address */
if (dev->info.type !=
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL)
--
1.7.0.4
--
Mit freundlichen Grüßen/Kind Regards
Viktor Mihajlovski
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
12 years, 5 months
[libvirt] [PATCH 2/5] S390: Change tests to use (modified) qemuDomainAssignAddresses
by Viktor Mihajlovski
Rewrote the device assignment parts in tests to use
qemuDomainAssignAddresses.
This way the tests will work for new device address types as they show
up in the future (like s390 device types).
Signed-off-by: Viktor Mihajlovski <mihajlov(a)linux.vnet.ibm.com>
---
tests/qemuxml2argvtest.c | 12 +-----------
tests/qemuxmlnstest.c | 13 ++-----------
2 files changed, 3 insertions(+), 22 deletions(-)
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 7b00ea2..3b339be 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -149,21 +149,11 @@ static int testCompareXMLToArgvFiles(const char *xml,
goto out;
if (qemuCapsGet(extraFlags, QEMU_CAPS_DEVICE)) {
- qemuDomainPCIAddressSetPtr pciaddrs;
-
- if (qemuDomainAssignSpaprVIOAddresses(vmdef)) {
+ if(qemuDomainAssignAddresses(vmdef, extraFlags, NULL)) {
if (expectError)
goto ok;
goto out;
}
-
- if (!(pciaddrs = qemuDomainPCIAddressSetCreate(vmdef)))
- goto out;
-
- if (qemuAssignDevicePCISlots(vmdef, pciaddrs) < 0)
- goto out;
-
- qemuDomainPCIAddressSetFree(pciaddrs);
}
log = virtTestLogContentAndReset();
diff --git a/tests/qemuxmlnstest.c b/tests/qemuxmlnstest.c
index 8eca466..0bc821d 100644
--- a/tests/qemuxmlnstest.c
+++ b/tests/qemuxmlnstest.c
@@ -95,17 +95,8 @@ static int testCompareXMLToArgvFiles(const char *xml,
if (qemudCanonicalizeMachine(&driver, vmdef) < 0)
goto fail;
- if (qemuCapsGet(extraFlags, QEMU_CAPS_DEVICE)) {
- qemuDomainPCIAddressSetPtr pciaddrs;
- if (!(pciaddrs = qemuDomainPCIAddressSetCreate(vmdef)))
- goto fail;
-
- if (qemuAssignDevicePCISlots(vmdef, pciaddrs) < 0)
- goto fail;
-
- qemuDomainPCIAddressSetFree(pciaddrs);
- }
-
+ if (qemuCapsGet(extraFlags, QEMU_CAPS_DEVICE))
+ qemuDomainAssignAddresses(vmdef, extraFlags, NULL);
log = virtTestLogContentAndReset();
VIR_FREE(log);
--
1.7.0.4
--
Mit freundlichen Grüßen/Kind Regards
Viktor Mihajlovski
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
12 years, 5 months
[libvirt] [PATCH 1/5] S390: Extended qemuDomainAssignAddresses to be callable from everywhere
by Viktor Mihajlovski
This is in preparation of the enablement of s390 guests with virtio devices.
The assignment of device addresses happens in different places, i.e. the
qemu driver and process modules as well as in the unit tests in slightly
different flavors. Currently, these are PPC spapr-vio and PCI
devices, virtio-s390 (not PCI based) will follow.
By optionally passing to qemuDomainAssignAddresses the domain
object and the capabilities it is now possible to call the function
from most of the places (except for hotplug) where address assignment
is done.
Signed-off-by: Viktor Mihajlovski <mihajlov(a)linux.vnet.ibm.com>
---
src/qemu/qemu_command.c | 42 +++++++++++++++++++++++++++++++++---------
src/qemu/qemu_command.h | 6 ++++--
src/qemu/qemu_driver.c | 14 +++++++-------
src/qemu/qemu_process.c | 42 ++++--------------------------------------
4 files changed, 48 insertions(+), 56 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index bd4f96a..bee48e1 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -941,16 +941,23 @@ cleanup:
int
-qemuDomainAssignPCIAddresses(virDomainDefPtr def)
+qemuDomainAssignPCIAddresses(virDomainDefPtr def, virBitmapPtr qemuCaps,
+ virDomainObjPtr obj)
{
int ret = -1;
- virBitmapPtr qemuCaps = NULL;
+ virBitmapPtr localCaps = NULL;
qemuDomainPCIAddressSetPtr addrs = NULL;
+ qemuDomainObjPrivatePtr priv = NULL;
- if (qemuCapsExtractVersionInfo(def->emulator, def->os.arch,
- NULL,
- &qemuCaps) < 0)
- goto cleanup;
+
+ if (!qemuCaps) {
+ /* need to get information from real environment */
+ if (qemuCapsExtractVersionInfo(def->emulator, def->os.arch,
+ NULL,
+ &localCaps) < 0)
+ goto cleanup;
+ qemuCaps = localCaps;
+ }
if (qemuCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
if (!(addrs = qemuDomainPCIAddressSetCreate(def)))
@@ -960,16 +967,33 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def)
goto cleanup;
}
+ if (obj && obj->privateData) {
+ priv = obj->privateData;
+ if (addrs) {
+ /* if this is the live domain object, we persist the PCI addresses*/
+ if (priv->pciaddrs) {
+ qemuDomainPCIAddressSetFree(priv->pciaddrs);
+ priv->pciaddrs = NULL;
+ }
+ priv->persistentAddrs = 1;
+ priv->pciaddrs = addrs;
+ addrs = NULL;
+ } else {
+ priv->persistentAddrs = 0;
+ }
+ }
+
ret = 0;
cleanup:
- qemuCapsFree(qemuCaps);
+ qemuCapsFree(localCaps);
qemuDomainPCIAddressSetFree(addrs);
return ret;
}
-int qemuDomainAssignAddresses(virDomainDefPtr def)
+int qemuDomainAssignAddresses(virDomainDefPtr def, virBitmapPtr qemuCaps,
+ virDomainObjPtr obj)
{
int rc;
@@ -977,7 +1001,7 @@ int qemuDomainAssignAddresses(virDomainDefPtr def)
if (rc)
return rc;
- return qemuDomainAssignPCIAddresses(def);
+ return qemuDomainAssignPCIAddresses(def, qemuCaps, obj);
}
static void
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index 1eafeb3..dd104d6 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -175,10 +175,12 @@ virDomainDefPtr qemuParseCommandLinePid(virCapsPtr caps,
virDomainChrSourceDefPtr *monConfig,
bool *monJSON);
-int qemuDomainAssignAddresses(virDomainDefPtr def);
+int qemuDomainAssignAddresses(virDomainDefPtr def, virBitmapPtr qemuCaps,
+ virDomainObjPtr);
int qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def);
-int qemuDomainAssignPCIAddresses(virDomainDefPtr def);
+int qemuDomainAssignPCIAddresses(virDomainDefPtr def, virBitmapPtr qemuCaps,
+ virDomainObjPtr obj);
qemuDomainPCIAddressSetPtr qemuDomainPCIAddressSetCreate(virDomainDefPtr def);
int qemuDomainPCIAddressReserveFunction(qemuDomainPCIAddressSetPtr addrs,
int slot, int function);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2177c30..7f53444 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1404,7 +1404,7 @@ static virDomainPtr qemudDomainCreate(virConnectPtr conn, const char *xml,
if (qemudCanonicalizeMachine(driver, def) < 0)
goto cleanup;
- if (qemuDomainAssignAddresses(def) < 0)
+ if (qemuDomainAssignAddresses(def, NULL, NULL) < 0)
goto cleanup;
if (!(vm = virDomainAssignDef(driver->caps,
@@ -5069,7 +5069,7 @@ static virDomainPtr qemudDomainDefine(virConnectPtr conn, const char *xml) {
if (qemudCanonicalizeMachine(driver, def) < 0)
goto cleanup;
- if (qemuDomainAssignAddresses(def) < 0)
+ if (qemuDomainAssignAddresses(def, NULL, NULL) < 0)
goto cleanup;
if (!(vm = virDomainAssignDef(driver->caps,
@@ -5547,7 +5547,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
if (disk->bus != VIR_DOMAIN_DISK_BUS_VIRTIO)
if (virDomainDefAddImplicitControllers(vmdef) < 0)
return -1;
- if (qemuDomainAssignAddresses(vmdef) < 0)
+ if (qemuDomainAssignAddresses(vmdef, NULL, NULL) < 0)
return -1;
break;
@@ -5565,7 +5565,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
return -1;
}
dev->data.net = NULL;
- if (qemuDomainAssignAddresses(vmdef) < 0)
+ if (qemuDomainAssignAddresses(vmdef, NULL, NULL) < 0)
return -1;
break;
@@ -5581,7 +5581,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
return -1;
}
dev->data.hostdev = NULL;
- if (qemuDomainAssignAddresses(vmdef) < 0)
+ if (qemuDomainAssignAddresses(vmdef, NULL, NULL) < 0)
return -1;
break;
@@ -5735,7 +5735,7 @@ qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef,
vmdef->nets[pos] = net;
dev->data.net = NULL;
- if (qemuDomainAssignAddresses(vmdef) < 0)
+ if (qemuDomainAssignAddresses(vmdef, NULL, NULL) < 0)
return -1;
break;
@@ -11733,7 +11733,7 @@ static virDomainPtr qemuDomainAttach(virConnectPtr conn,
if (qemudCanonicalizeMachine(driver, def) < 0)
goto cleanup;
- if (qemuDomainAssignAddresses(def) < 0)
+ if (qemuDomainAssignAddresses(def, NULL, NULL) < 0)
goto cleanup;
if (!(vm = virDomainAssignDef(driver->caps,
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 1df3637..e8461b3 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3090,13 +3090,8 @@ qemuProcessReconnect(void *opaque)
goto endjob;
}
- if (qemuCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
- priv->persistentAddrs = 1;
-
- if (!(priv->pciaddrs = qemuDomainPCIAddressSetCreate(obj->def)) ||
- qemuAssignDevicePCISlots(obj->def, priv->pciaddrs) < 0)
- goto error;
- }
+ if (qemuCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE))
+ qemuDomainAssignAddresses(obj->def, priv->qemuCaps, obj);
if (virSecurityManagerReserveLabel(driver->securityManager, obj->def, obj->pid) < 0)
goto error;
@@ -3539,22 +3534,7 @@ int qemuProcessStart(virConnectPtr conn,
*/
if (qemuCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
VIR_DEBUG("Assigning domain PCI addresses");
- /* Populate cache with current addresses */
- if (priv->pciaddrs) {
- qemuDomainPCIAddressSetFree(priv->pciaddrs);
- priv->pciaddrs = NULL;
- }
- if (!(priv->pciaddrs = qemuDomainPCIAddressSetCreate(vm->def)))
- goto cleanup;
-
-
- /* Assign any remaining addresses */
- if (qemuAssignDevicePCISlots(vm->def, priv->pciaddrs) < 0)
- goto cleanup;
-
- priv->persistentAddrs = 1;
- } else {
- priv->persistentAddrs = 0;
+ qemuDomainAssignAddresses(vm->def, priv->qemuCaps, vm);
}
VIR_DEBUG("Building emulator command line");
@@ -4236,21 +4216,7 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED,
*/
if (qemuCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
VIR_DEBUG("Assigning domain PCI addresses");
- /* Populate cache with current addresses */
- if (priv->pciaddrs) {
- qemuDomainPCIAddressSetFree(priv->pciaddrs);
- priv->pciaddrs = NULL;
- }
- if (!(priv->pciaddrs = qemuDomainPCIAddressSetCreate(vm->def)))
- goto cleanup;
-
- /* Assign any remaining addresses */
- if (qemuAssignDevicePCISlots(vm->def, priv->pciaddrs) < 0)
- goto cleanup;
-
- priv->persistentAddrs = 1;
- } else {
- priv->persistentAddrs = 0;
+ qemuDomainAssignAddresses(vm->def, priv->qemuCaps, vm);
}
if ((timestamp = virTimeStringNow()) == NULL) {
--
1.7.0.4
--
Mit freundlichen Grüßen/Kind Regards
Viktor Mihajlovski
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
12 years, 5 months
[libvirt] [PATCH 0/5] Virtio support for S390
by Viktor Mihajlovski
This series adds support for the s390 flavor of virtio devices.
Since the s390 virtio devices are not implemented as PCI devices
it is necessary to refactor some of the device address assignment
code.
Viktor Mihajlovski (5):
S390: Extended qemuDomainAssignAddresses to be callable from
everywhere.
S390: Change tests to use (modified) qemuDomainAssignAddresses
S390: Add support for virtio-s390 devices.
S390: Domain Schema for s390-virtio machines.
S390: Adding testcases for s390
docs/schemas/domaincommon.rng | 20 +++
src/conf/domain_conf.c | 11 +-
src/conf/domain_conf.h | 1 +
src/qemu/qemu_capabilities.c | 7 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 140 ++++++++++++++++++--
src/qemu/qemu_command.h | 6 +-
src/qemu/qemu_driver.c | 14 +-
src/qemu/qemu_process.c | 42 +------
.../qemuxml2argv-console-virtio-s390.args | 9 ++
.../qemuxml2argv-console-virtio-s390.xml | 24 ++++
.../qemuxml2argv-disk-virtio-s390.args | 5 +
.../qemuxml2argv-disk-virtio-s390.xml | 22 +++
.../qemuxml2argv-minimal-s390.args | 5 +
.../qemuxml2argvdata/qemuxml2argv-minimal-s390.xml | 21 +++
.../qemuxml2argv-net-virtio-s390.args | 5 +
.../qemuxml2argv-net-virtio-s390.xml | 22 +++
tests/qemuxml2argvtest.c | 20 ++--
tests/qemuxmlnstest.c | 13 +--
tests/testutilsqemu.c | 31 +++++
20 files changed, 333 insertions(+), 86 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-console-virtio-s390.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-console-virtio-s390.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-s390.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-s390.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-minimal-s390.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-minimal-s390.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-virtio-s390.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-virtio-s390.xml
--
Mit freundlichen Grüßen/Kind Regards
Viktor Mihajlovski
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
12 years, 5 months
[libvirt] [PATCH 5/5] S390: Added sysinfo for host on s390x.
by Viktor Mihajlovski
In order to retrieve some sysinfo data we need to parse /proc/sysinfo and
/proc/cpuinfo.
Signed-off-by: Thang Pham <thang.pham(a)us.ibm.com>
Signed-off-by: Viktor Mihajlovski <mihajlov(a)linux.vnet.ibm.com>
---
src/util/sysinfo.c | 154 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 154 insertions(+), 0 deletions(-)
diff --git a/src/util/sysinfo.c b/src/util/sysinfo.c
index 78efc32..01cce98 100644
--- a/src/util/sysinfo.c
+++ b/src/util/sysinfo.c
@@ -44,6 +44,7 @@
__FUNCTION__, __LINE__, __VA_ARGS__)
#define SYSINFO_SMBIOS_DECODER "dmidecode"
+#define SYSINFO "/proc/sysinfo"
#define CPUINFO "/proc/cpuinfo"
VIR_ENUM_IMPL(virSysinfo, VIR_SYSINFO_LAST,
@@ -241,6 +242,159 @@ no_memory:
return NULL;
}
+#elif defined(__s390__) || defined(__s390x__)
+
+static int
+virSysinfoParseSystem(const char *base, virSysinfoDefPtr ret)
+{
+ char *cur, *eol = NULL;
+ const char *property;
+
+ /* Return if Manufacturer field is not found */
+ if ((cur = strstr(base, "Manufacturer")) == NULL)
+ return 0;
+
+ base = cur;
+ if ((cur = strstr(base, "Manufacturer")) != NULL) {
+ cur = strchr(cur, ':') + 1;
+ eol = strchr(cur, '\n');
+ virSkipSpacesBackwards(cur, &eol);
+ if ((eol) && ((property = strndup(cur, eol - cur)) == NULL))
+ goto no_memory;
+ virSkipSpaces(&property);
+ ret->system_manufacturer = (char *) property;
+ }
+ if ((cur = strstr(base, "Type")) != NULL) {
+ cur = strchr(cur, ':') + 1;
+ eol = strchr(cur, '\n');
+ virSkipSpacesBackwards(cur, &eol);
+ if ((eol) && ((property = strndup(cur, eol - cur)) == NULL))
+ goto no_memory;
+ virSkipSpaces(&property);
+ ret->system_family = (char *) property;
+ }
+ if ((cur = strstr(base, "Sequence Code")) != NULL) {
+ cur = strchr(cur, ':') + 1;
+ eol = strchr(cur, '\n');
+ virSkipSpacesBackwards(cur, &eol);
+ if ((eol) && ((property = strndup(cur, eol - cur)) == NULL))
+ goto no_memory;
+ virSkipSpaces(&property);
+ ret->system_serial = (char *) property;
+ }
+
+ return 0;
+
+no_memory:
+ return -1;
+}
+
+static int
+virSysinfoParseProcessor(const char *base, virSysinfoDefPtr ret)
+{
+ char *cur, *eol, *tmp_base;
+ char *manufacturer;
+ const char *tmp;
+ virSysinfoProcessorDefPtr processor;
+
+ if ((cur = strstr(base, "vendor_id")) != NULL) {
+ cur = strchr(cur, ':') + 1;
+ eol = strchr(cur, '\n');
+ virSkipSpacesBackwards(cur, &eol);
+ if ((eol) && ((tmp = strndup(cur, eol - cur)) == NULL))
+ goto no_memory;
+ virSkipSpaces(&tmp);
+ manufacturer = (char *) tmp;
+ }
+
+ /* Find processor N: line and gather the processor manufacturer, version, serial number, and family */
+ while((tmp_base = strstr(base, "processor ")) != NULL) {
+ base = tmp_base;
+ eol = strchr(base, '\n');
+ cur = strchr(base, ':') + 1;
+
+ if (VIR_EXPAND_N(ret->processor, ret->nprocessor, 1) < 0) {
+ goto no_memory;
+ }
+
+ processor = &ret->processor[ret->nprocessor - 1];
+
+ /* Set the processor manufacturer */
+ processor->processor_manufacturer = manufacturer;
+
+ if ((cur = strstr(base, "version =")) != NULL) {
+ cur += sizeof("version =");
+ eol = strchr(cur, ',');
+ if ((eol) &&
+ ((processor->processor_version = strndup(cur, eol - cur)) == NULL))
+ goto no_memory;
+ }
+ if ((cur = strstr(base, "identification =")) != NULL) {
+ cur += sizeof("identification =");
+ eol = strchr(cur, ',');
+ if ((eol) &&
+ ((processor->processor_serial_number = strndup(cur, eol - cur)) == NULL))
+ goto no_memory;
+ }
+ if ((cur = strstr(base, "machine =")) != NULL) {
+ cur += sizeof("machine =");
+ eol = strchr(cur, '\n');
+ if ((eol) &&
+ ((processor->processor_family = strndup(cur, eol - cur)) == NULL))
+ goto no_memory;
+ }
+
+ base = cur;
+ }
+
+ return 0;
+
+no_memory:
+ return -1;
+}
+
+/* virSysinfoRead for s390x
+ * Gathers sysinfo data from /proc/sysinfo and /proc/cpuinfo */
+virSysinfoDefPtr
+virSysinfoRead(void) {
+ virSysinfoDefPtr ret = NULL;
+ char *outbuf = NULL;
+
+ if (VIR_ALLOC(ret) < 0)
+ goto no_memory;
+
+ /* Gather info from /proc/cpuinfo */
+ if(virFileReadAll(CPUINFO, 2048, &outbuf) < 0) {
+ virSmbiosReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to open %s"), CPUINFO);
+ return NULL;
+ }
+
+ ret->nprocessor = 0;
+ ret->processor = NULL;
+ if (virSysinfoParseProcessor(outbuf, ret) < 0)
+ goto no_memory;
+
+ /* Free buffer before reading next file */
+ VIR_FREE(outbuf);
+
+ /* Gather info from /proc/sysinfo */
+ if(virFileReadAll(SYSINFO, 4096, &outbuf) < 0) {
+ virSmbiosReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to open %s"), SYSINFO);
+ return NULL;
+ }
+
+ if (virSysinfoParseSystem(outbuf, ret) < 0)
+ goto no_memory;
+
+ return ret;
+
+no_memory:
+ VIR_FREE(outbuf);
+ return NULL;
+}
+
#elif defined(WIN32) || \
!(defined(__x86_64__) || \
defined(__i386__) || \
--
1.7.0.4
--
Mit freundlichen Grüßen/Kind Regards
Viktor Mihajlovski
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
12 years, 5 months
[libvirt] [PATCH 4/5] S390: Fixed core identification for s390
by Viktor Mihajlovski
For the s390x architecture the sysfs core_id alone is not unique. As a
result it can happen that libvirt thinks there are less host CPUs available
than really present.
Currently, a logical CPU is equivalent to a core for s390x. We therefore
produce a fake core id from the CPU number.
Signed-off-by: Viktor Mihajlovski <mihajlov(a)linux.vnet.ibm.com>
---
src/nodeinfo.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 7eb5ae5..819f954 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -355,7 +355,13 @@ int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
nodeinfo->cpus++;
/* Parse core */
+# if defined(__s390__) || \
+ defined(__s390x__)
+ /* logical cpu is equivalent to a core on s390 */
+ core = cpu;
+# else
core = virNodeGetCpuValue(sysfs_cpudir, cpu,
"topology/core_id", false);
+# endif
if (!CPU_ISSET(core, &core_mask)) {
CPU_SET(core, &core_mask);
nodeinfo->cores++;
--
1.7.0.4
--
Mit freundlichen Grüßen/Kind Regards
Viktor Mihajlovski
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
12 years, 5 months
[libvirt] [PATCH 3/5] S390: Fixed Parser for /proc/cpuinfo needs to be adapted for your architecture
by Viktor Mihajlovski
Minimal CPU "parser" for s390 to avoid compile time warning.
Signed-off-by: Thang Pham <thang.pham(a)us.ibm.com>
Signed-off-by: Viktor Mihajlovski <mihajlov(a)linux.vnet.ibm.com>
---
src/nodeinfo.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index f7d0cc6..7eb5ae5 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -315,6 +315,11 @@ int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
* and parsed in next iteration, because it is not in expected
* format and thus lead to error. */
}
+# elif defined(__s390__) || \
+ defined(__s390x__)
+ /* s390x has no realistic value for CPU speed,
+ * assign a value of zero to signify this */
+ nodeinfo->mhz = 0;
# else
# warning Parser for /proc/cpuinfo needs to be adapted for your
architecture
# endif
--
1.7.0.4
--
Mit freundlichen Grüßen/Kind Regards
Viktor Mihajlovski
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
12 years, 5 months
[libvirt] [PATCH 2/5] S390: CPU support for s390(x)
by Viktor Mihajlovski
Adding CPU encoder/decoder for s390 to avoid runtime error messages.
Signed-off-by: Thang Pham <thang.pham(a)us.ibm.com>
Signed-off-by: Viktor Mihajlovski <mihajlov(a)linux.vnet.ibm.com>
---
src/Makefile.am | 1 +
src/cpu/cpu.c | 2 +
src/cpu/cpu_s390x.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++
src/cpu/cpu_s390x.h | 31 +++++++++++++++++++
4 files changed, 114 insertions(+), 0 deletions(-)
create mode 100644 src/cpu/cpu_s390x.c
create mode 100644 src/cpu/cpu_s390x.h
diff --git a/src/Makefile.am b/src/Makefile.am
index e40909b..b0bd3e8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -566,6 +566,7 @@ CPU_SOURCES = \
cpu/cpu.h cpu/cpu.c \
cpu/cpu_generic.h cpu/cpu_generic.c \
cpu/cpu_x86.h cpu/cpu_x86.c cpu/cpu_x86_data.h \
+ cpu/cpu_s390x.h cpu/cpu_s390x.c \
cpu/cpu_map.h cpu/cpu_map.c cpu/cpu_powerpc.h \
cpu/cpu_powerpc.c
diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c
index b8ccd24..08cb144 100644
--- a/src/cpu/cpu.c
+++ b/src/cpu/cpu.c
@@ -29,6 +29,7 @@
#include "cpu.h"
#include "cpu_x86.h"
#include "cpu_powerpc.h"
+#include "cpu_s390x.h"
#include "cpu_generic.h"
@@ -38,6 +39,7 @@
static struct cpuArchDriver *drivers[] = {
&cpuDriverX86,
&cpuDriverPowerPC,
+ &cpuDriverS390X,
/* generic driver must always be the last one */
&cpuDriverGeneric
};
diff --git a/src/cpu/cpu_s390x.c b/src/cpu/cpu_s390x.c
new file mode 100644
index 0000000..da45433
--- /dev/null
+++ b/src/cpu/cpu_s390x.c
@@ -0,0 +1,80 @@
+/*
+ * cpu_s390x.c: CPU driver for s390x CPUs
+ *
+ * Copyright IBM Corp. 2012
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Authors:
+ * Thang Pham <thang.pham(a)us.ibm.com>
+ */
+
+#include <config.h>
+
+#include "memory.h"
+#include "cpu.h"
+
+
+#define VIR_FROM_THIS VIR_FROM_CPU
+
+static const char *archs[] = { "s390", "s390x" };
+
+static union cpuData *
+s390xNodeData(void)
+{
+ union cpuData *data;
+
+ if (VIR_ALLOC(data) < 0) {
+ virReportOOMError();
+ return NULL;
+ }
+
+ return data;
+}
+
+
+static int
+s390xDecode(virCPUDefPtr cpu ATTRIBUTE_UNUSED,
+ const union cpuData *data ATTRIBUTE_UNUSED,
+ const char **models ATTRIBUTE_UNUSED,
+ unsigned int nmodels ATTRIBUTE_UNUSED,
+ const char *preferred ATTRIBUTE_UNUSED)
+{
+ return 0;
+}
+
+static void
+s390xDataFree(union cpuData *data)
+{
+ if (data == NULL)
+ return;
+
+ VIR_FREE(data);
+}
+
+struct cpuArchDriver cpuDriverS390X = {
+ .name = "s390x",
+ .arch = archs,
+ .narch = ARRAY_CARDINALITY(archs),
+ .compare = NULL,
+ .decode = s390xDecode,
+ .encode = NULL,
+ .free = s390xDataFree,
+ .nodeData = s390xNodeData,
+ .guestData = NULL,
+ .baseline = NULL,
+ .update = NULL,
+ .hasFeature = NULL,
+};
diff --git a/src/cpu/cpu_s390x.h b/src/cpu/cpu_s390x.h
new file mode 100644
index 0000000..f91377f
--- /dev/null
+++ b/src/cpu/cpu_s390x.h
@@ -0,0 +1,31 @@
+/*
+ * cpu_s390x.c: CPU driver for s390x CPUs
+ *
+ * Copyright IBM Corp. 2012
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Authors:
+ * Thang Pham <thang.pham(a)us.ibm.com>
+ */
+
+#ifndef __VIR_CPU_S390X_H__
+# define __VIR_CPU_S390X_H__
+
+# include "cpu.h"
+
+extern struct cpuArchDriver cpuDriverS390X;
+
+#endif /* __VIR_CPU_S390X_H__ */
--
1.7.0.4
--
Mit freundlichen Grüßen/Kind Regards
Viktor Mihajlovski
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
12 years, 5 months