import qemu-kvm-4.2.0-35.module+el8.4.0+8453+f5da6c50
This commit is contained in:
parent
6f7fb16b8c
commit
6b491f095c
@ -0,0 +1,104 @@
|
||||
From 4b4fb1cccb8e0307658cee3bc90c77e5f1dde60a Mon Sep 17 00:00:00 2001
|
||||
From: Thomas Huth <thuth@redhat.com>
|
||||
Date: Fri, 9 Oct 2020 10:08:49 -0400
|
||||
Subject: [PATCH 13/14] aio-posix: completely stop polling when disabled
|
||||
|
||||
RH-Author: Thomas Huth <thuth@redhat.com>
|
||||
Message-id: <20201009100849.264994-10-thuth@redhat.com>
|
||||
Patchwork-id: 98603
|
||||
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH 9/9] aio-posix: completely stop polling when disabled
|
||||
Bugzilla: 1846975
|
||||
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
|
||||
RH-Acked-by: David Hildenbrand <david@redhat.com>
|
||||
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
||||
|
||||
From: Stefan Hajnoczi <stefanha@redhat.com>
|
||||
|
||||
One iteration of polling is always performed even when polling is
|
||||
disabled. This is done because:
|
||||
1. Userspace polling is cheaper than making a syscall. We might get
|
||||
lucky.
|
||||
2. We must poll once more after polling has stopped in case an event
|
||||
occurred while stopping polling.
|
||||
|
||||
However, there are downsides:
|
||||
1. Polling becomes a bottleneck when the number of event sources is very
|
||||
high. It's more efficient to monitor fds in that case.
|
||||
2. A high-frequency polling event source can starve non-polling event
|
||||
sources because ppoll(2)/epoll(7) is never invoked.
|
||||
|
||||
This patch removes the forced polling iteration so that poll_ns=0 really
|
||||
means no polling.
|
||||
|
||||
IOPS increases from 10k to 60k when the guest has 100
|
||||
virtio-blk-pci,num-queues=32 devices and 1 virtio-blk-pci,num-queues=1
|
||||
device because the large number of event sources being polled slows down
|
||||
the event loop.
|
||||
|
||||
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
||||
Link: https://lore.kernel.org/r/20200305170806.1313245-2-stefanha@redhat.com
|
||||
Message-Id: <20200305170806.1313245-2-stefanha@redhat.com>
|
||||
(cherry picked from commit e4346192f1c2e1683a807b46efac47ef0cf9b545)
|
||||
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
||||
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
||||
---
|
||||
util/aio-posix.c | 22 +++++++++++++++-------
|
||||
1 file changed, 15 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/util/aio-posix.c b/util/aio-posix.c
|
||||
index a4977f538e..abc396d030 100644
|
||||
--- a/util/aio-posix.c
|
||||
+++ b/util/aio-posix.c
|
||||
@@ -340,12 +340,13 @@ void aio_set_event_notifier_poll(AioContext *ctx,
|
||||
(IOHandler *)io_poll_end);
|
||||
}
|
||||
|
||||
-static void poll_set_started(AioContext *ctx, bool started)
|
||||
+static bool poll_set_started(AioContext *ctx, bool started)
|
||||
{
|
||||
AioHandler *node;
|
||||
+ bool progress = false;
|
||||
|
||||
if (started == ctx->poll_started) {
|
||||
- return;
|
||||
+ return false;
|
||||
}
|
||||
|
||||
ctx->poll_started = started;
|
||||
@@ -367,8 +368,15 @@ static void poll_set_started(AioContext *ctx, bool started)
|
||||
if (fn) {
|
||||
fn(node->opaque);
|
||||
}
|
||||
+
|
||||
+ /* Poll one last time in case ->io_poll_end() raced with the event */
|
||||
+ if (!started) {
|
||||
+ progress = node->io_poll(node->opaque) || progress;
|
||||
+ }
|
||||
}
|
||||
qemu_lockcnt_dec(&ctx->list_lock);
|
||||
+
|
||||
+ return progress;
|
||||
}
|
||||
|
||||
|
||||
@@ -599,12 +607,12 @@ static bool try_poll_mode(AioContext *ctx, int64_t *timeout)
|
||||
}
|
||||
}
|
||||
|
||||
- poll_set_started(ctx, false);
|
||||
+ if (poll_set_started(ctx, false)) {
|
||||
+ *timeout = 0;
|
||||
+ return true;
|
||||
+ }
|
||||
|
||||
- /* Even if we don't run busy polling, try polling once in case it can make
|
||||
- * progress and the caller will be able to avoid ppoll(2)/epoll_wait(2).
|
||||
- */
|
||||
- return run_poll_handlers_once(ctx, timeout);
|
||||
+ return false;
|
||||
}
|
||||
|
||||
bool aio_poll(AioContext *ctx, bool blocking)
|
||||
--
|
||||
2.27.0
|
||||
|
@ -0,0 +1,250 @@
|
||||
From aac48d07764ce73c2ba23e3f05ccd29db190024a Mon Sep 17 00:00:00 2001
|
||||
From: Greg Kurz <gkurz@redhat.com>
|
||||
Date: Thu, 8 Oct 2020 11:06:43 -0400
|
||||
Subject: [PATCH 04/14] nvram: Exit QEMU if NVRAM cannot contain all -prom-env
|
||||
data
|
||||
|
||||
RH-Author: Greg Kurz <gkurz@redhat.com>
|
||||
Message-id: <20201008110643.155902-2-gkurz@redhat.com>
|
||||
Patchwork-id: 98577
|
||||
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH 1/1] nvram: Exit QEMU if NVRAM cannot contain all -prom-env data
|
||||
Bugzilla: 1874780
|
||||
RH-Acked-by: David Gibson <dgibson@redhat.com>
|
||||
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
|
||||
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
||||
|
||||
From: Greg Kurz <groug@kaod.org>
|
||||
|
||||
Since commit 61f20b9dc5b7 ("spapr_nvram: Pre-initialize the NVRAM to
|
||||
support the -prom-env parameter"), pseries machines can pre-initialize
|
||||
the "system" partition in the NVRAM with the data passed to all -prom-env
|
||||
parameters on the QEMU command line.
|
||||
|
||||
In this case it is assumed that all the data fits in 64 KiB, but the user
|
||||
can easily pass more and crash QEMU:
|
||||
|
||||
$ qemu-system-ppc64 -M pseries $(for ((x=0;x<128;x++)); do \
|
||||
echo -n " -prom-env " ; printf "%0.sx" {1..1024}; \
|
||||
done) # this requires ~128 Kib
|
||||
malloc(): corrupted top size
|
||||
Aborted (core dumped)
|
||||
|
||||
This happens because we don't check if all the prom-env data fits in
|
||||
the NVRAM and chrp_nvram_set_var() happily memcpy() it passed the
|
||||
buffer.
|
||||
|
||||
This crash affects basically all ppc/ppc64 machine types that use -prom-env:
|
||||
- pseries (all versions)
|
||||
- g3beige
|
||||
- mac99
|
||||
|
||||
and also sparc/sparc64 machine types:
|
||||
- LX
|
||||
- SPARCClassic
|
||||
- SPARCbook
|
||||
- SS-10
|
||||
- SS-20
|
||||
- SS-4
|
||||
- SS-5
|
||||
- SS-600MP
|
||||
- Voyager
|
||||
- sun4u
|
||||
- sun4v
|
||||
|
||||
Add a max_len argument to chrp_nvram_create_system_partition() so that
|
||||
it can check the available size before writing to memory.
|
||||
|
||||
Since NVRAM is populated at machine init, it seems reasonable to consider
|
||||
this error as fatal. So, instead of reporting an error when we detect that
|
||||
the NVRAM is too small and adapt all machine types to handle it, we simply
|
||||
exit QEMU in all cases. This is still better than crashing. If someone
|
||||
wants another behavior, I guess this can be reworked later.
|
||||
|
||||
Tested with:
|
||||
|
||||
$ yes q | \
|
||||
(for arch in ppc ppc64 sparc sparc64; do \
|
||||
echo == $arch ==; \
|
||||
qemu=${arch}-softmmu/qemu-system-$arch; \
|
||||
for mach in $($qemu -M help | awk '! /^Supported/ { print $1 }'); do \
|
||||
echo $mach; \
|
||||
$qemu -M $mach -monitor stdio -nodefaults -nographic \
|
||||
$(for ((x=0;x<128;x++)); do \
|
||||
echo -n " -prom-env " ; printf "%0.sx" {1..1024}; \
|
||||
done) >/dev/null; \
|
||||
done; echo; \
|
||||
done)
|
||||
|
||||
Without the patch, affected machine types cause QEMU to report some
|
||||
memory corruption and crash:
|
||||
|
||||
malloc(): corrupted top size
|
||||
|
||||
free(): invalid size
|
||||
|
||||
*** stack smashing detected ***: terminated
|
||||
|
||||
With the patch, QEMU prints the following message and exits:
|
||||
|
||||
NVRAM is too small. Try to pass less data to -prom-env
|
||||
|
||||
It seems that the conditions for the crash have always existed, but it
|
||||
affects pseries, the machine type I care for, since commit 61f20b9dc5b7
|
||||
only.
|
||||
|
||||
Fixes: 61f20b9dc5b7 ("spapr_nvram: Pre-initialize the NVRAM to support the -prom-env parameter")
|
||||
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1867739
|
||||
Reported-by: John Snow <jsnow@redhat.com>
|
||||
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
|
||||
Signed-off-by: Greg Kurz <groug@kaod.org>
|
||||
Message-Id: <159736033937.350502.12402444542194031035.stgit@bahia.lan>
|
||||
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
|
||||
(cherry picked from commit 37035df51eaabb8d26b71da75b88a1c6727de8fa)
|
||||
Signed-off-by: Greg Kurz <gkurz@redhat.com>
|
||||
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
||||
---
|
||||
hw/nvram/chrp_nvram.c | 24 +++++++++++++++++++++---
|
||||
hw/nvram/mac_nvram.c | 2 +-
|
||||
hw/nvram/spapr_nvram.c | 3 ++-
|
||||
hw/sparc/sun4m.c | 2 +-
|
||||
hw/sparc64/sun4u.c | 2 +-
|
||||
include/hw/nvram/chrp_nvram.h | 3 ++-
|
||||
6 files changed, 28 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/hw/nvram/chrp_nvram.c b/hw/nvram/chrp_nvram.c
|
||||
index d969f26704..d4d10a7c03 100644
|
||||
--- a/hw/nvram/chrp_nvram.c
|
||||
+++ b/hw/nvram/chrp_nvram.c
|
||||
@@ -21,14 +21,21 @@
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu/cutils.h"
|
||||
+#include "qemu/error-report.h"
|
||||
#include "hw/nvram/chrp_nvram.h"
|
||||
#include "sysemu/sysemu.h"
|
||||
|
||||
-static int chrp_nvram_set_var(uint8_t *nvram, int addr, const char *str)
|
||||
+static int chrp_nvram_set_var(uint8_t *nvram, int addr, const char *str,
|
||||
+ int max_len)
|
||||
{
|
||||
int len;
|
||||
|
||||
len = strlen(str) + 1;
|
||||
+
|
||||
+ if (max_len < len) {
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
memcpy(&nvram[addr], str, len);
|
||||
|
||||
return addr + len;
|
||||
@@ -38,19 +45,26 @@ static int chrp_nvram_set_var(uint8_t *nvram, int addr, const char *str)
|
||||
* Create a "system partition", used for the Open Firmware
|
||||
* environment variables.
|
||||
*/
|
||||
-int chrp_nvram_create_system_partition(uint8_t *data, int min_len)
|
||||
+int chrp_nvram_create_system_partition(uint8_t *data, int min_len, int max_len)
|
||||
{
|
||||
ChrpNvramPartHdr *part_header;
|
||||
unsigned int i;
|
||||
int end;
|
||||
|
||||
+ if (max_len < sizeof(*part_header)) {
|
||||
+ goto fail;
|
||||
+ }
|
||||
+
|
||||
part_header = (ChrpNvramPartHdr *)data;
|
||||
part_header->signature = CHRP_NVPART_SYSTEM;
|
||||
pstrcpy(part_header->name, sizeof(part_header->name), "system");
|
||||
|
||||
end = sizeof(ChrpNvramPartHdr);
|
||||
for (i = 0; i < nb_prom_envs; i++) {
|
||||
- end = chrp_nvram_set_var(data, end, prom_envs[i]);
|
||||
+ end = chrp_nvram_set_var(data, end, prom_envs[i], max_len - end);
|
||||
+ if (end == -1) {
|
||||
+ goto fail;
|
||||
+ }
|
||||
}
|
||||
|
||||
/* End marker */
|
||||
@@ -65,6 +79,10 @@ int chrp_nvram_create_system_partition(uint8_t *data, int min_len)
|
||||
chrp_nvram_finish_partition(part_header, end);
|
||||
|
||||
return end;
|
||||
+
|
||||
+fail:
|
||||
+ error_report("NVRAM is too small. Try to pass less data to -prom-env");
|
||||
+ exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/**
|
||||
diff --git a/hw/nvram/mac_nvram.c b/hw/nvram/mac_nvram.c
|
||||
index 9a47e35b8e..ecfb36182f 100644
|
||||
--- a/hw/nvram/mac_nvram.c
|
||||
+++ b/hw/nvram/mac_nvram.c
|
||||
@@ -152,7 +152,7 @@ static void pmac_format_nvram_partition_of(MacIONVRAMState *nvr, int off,
|
||||
|
||||
/* OpenBIOS nvram variables partition */
|
||||
sysp_end = chrp_nvram_create_system_partition(&nvr->data[off],
|
||||
- DEF_SYSTEM_SIZE) + off;
|
||||
+ DEF_SYSTEM_SIZE, len) + off;
|
||||
|
||||
/* Free space partition */
|
||||
chrp_nvram_create_free_partition(&nvr->data[sysp_end], len - sysp_end);
|
||||
diff --git a/hw/nvram/spapr_nvram.c b/hw/nvram/spapr_nvram.c
|
||||
index 838082b451..225cd69b49 100644
|
||||
--- a/hw/nvram/spapr_nvram.c
|
||||
+++ b/hw/nvram/spapr_nvram.c
|
||||
@@ -188,7 +188,8 @@ static void spapr_nvram_realize(SpaprVioDevice *dev, Error **errp)
|
||||
}
|
||||
} else if (nb_prom_envs > 0) {
|
||||
/* Create a system partition to pass the -prom-env variables */
|
||||
- chrp_nvram_create_system_partition(nvram->buf, MIN_NVRAM_SIZE / 4);
|
||||
+ chrp_nvram_create_system_partition(nvram->buf, MIN_NVRAM_SIZE / 4,
|
||||
+ nvram->size);
|
||||
chrp_nvram_create_free_partition(&nvram->buf[MIN_NVRAM_SIZE / 4],
|
||||
nvram->size - MIN_NVRAM_SIZE / 4);
|
||||
}
|
||||
diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
|
||||
index 2aaa5bf1ae..cf2d0762d9 100644
|
||||
--- a/hw/sparc/sun4m.c
|
||||
+++ b/hw/sparc/sun4m.c
|
||||
@@ -142,7 +142,7 @@ static void nvram_init(Nvram *nvram, uint8_t *macaddr,
|
||||
memset(image, '\0', sizeof(image));
|
||||
|
||||
/* OpenBIOS nvram variables partition */
|
||||
- sysp_end = chrp_nvram_create_system_partition(image, 0);
|
||||
+ sysp_end = chrp_nvram_create_system_partition(image, 0, 0x1fd0);
|
||||
|
||||
/* Free space partition */
|
||||
chrp_nvram_create_free_partition(&image[sysp_end], 0x1fd0 - sysp_end);
|
||||
diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
|
||||
index 955082773b..f5295a687e 100644
|
||||
--- a/hw/sparc64/sun4u.c
|
||||
+++ b/hw/sparc64/sun4u.c
|
||||
@@ -137,7 +137,7 @@ static int sun4u_NVRAM_set_params(Nvram *nvram, uint16_t NVRAM_size,
|
||||
memset(image, '\0', sizeof(image));
|
||||
|
||||
/* OpenBIOS nvram variables partition */
|
||||
- sysp_end = chrp_nvram_create_system_partition(image, 0);
|
||||
+ sysp_end = chrp_nvram_create_system_partition(image, 0, 0x1fd0);
|
||||
|
||||
/* Free space partition */
|
||||
chrp_nvram_create_free_partition(&image[sysp_end], 0x1fd0 - sysp_end);
|
||||
diff --git a/include/hw/nvram/chrp_nvram.h b/include/hw/nvram/chrp_nvram.h
|
||||
index 09941a9be4..4a0f5c21b8 100644
|
||||
--- a/include/hw/nvram/chrp_nvram.h
|
||||
+++ b/include/hw/nvram/chrp_nvram.h
|
||||
@@ -50,7 +50,8 @@ chrp_nvram_finish_partition(ChrpNvramPartHdr *header, uint32_t size)
|
||||
header->checksum = sum & 0xff;
|
||||
}
|
||||
|
||||
-int chrp_nvram_create_system_partition(uint8_t *data, int min_len);
|
||||
+/* chrp_nvram_create_system_partition() failure is fatal */
|
||||
+int chrp_nvram_create_system_partition(uint8_t *data, int min_len, int max_len);
|
||||
int chrp_nvram_create_free_partition(uint8_t *data, int len);
|
||||
|
||||
#endif
|
||||
--
|
||||
2.27.0
|
||||
|
@ -0,0 +1,112 @@
|
||||
From e46aaac6f1ad67753face896e827ad1da920b9e5 Mon Sep 17 00:00:00 2001
|
||||
From: Thomas Huth <thuth@redhat.com>
|
||||
Date: Fri, 9 Oct 2020 10:08:47 -0400
|
||||
Subject: [PATCH 11/14] pc-bios/s390-ccw: Allow booting in case the first
|
||||
virtio-blk disk is bad
|
||||
|
||||
RH-Author: Thomas Huth <thuth@redhat.com>
|
||||
Message-id: <20201009100849.264994-8-thuth@redhat.com>
|
||||
Patchwork-id: 98601
|
||||
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH 7/9] pc-bios/s390-ccw: Allow booting in case the first virtio-blk disk is bad
|
||||
Bugzilla: 1846975
|
||||
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
|
||||
RH-Acked-by: David Hildenbrand <david@redhat.com>
|
||||
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
||||
|
||||
If you try to boot with two virtio-blk disks (without bootindex), and
|
||||
only the second one is bootable, the s390-ccw bios currently stops at
|
||||
the first disk and does not continue booting from the second one. This
|
||||
is annoying - and all other major QEMU firmwares succeed to boot from
|
||||
the second disk in this case, so we should do the same in the s390-ccw
|
||||
bios, too.
|
||||
|
||||
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
|
||||
Message-Id: <20200806105349.632-8-thuth@redhat.com>
|
||||
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
||||
(cherry picked from commit 5dc739f343cd06ecb9b058294564ce7504856f3f)
|
||||
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
||||
---
|
||||
pc-bios/s390-ccw/bootmap.c | 34 +++++++++++++++++++++++-----------
|
||||
pc-bios/s390-ccw/main.c | 2 +-
|
||||
2 files changed, 24 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c
|
||||
index d13b7cbd15..e91ea719ff 100644
|
||||
--- a/pc-bios/s390-ccw/bootmap.c
|
||||
+++ b/pc-bios/s390-ccw/bootmap.c
|
||||
@@ -289,11 +289,18 @@ static void ipl_eckd_cdl(void)
|
||||
read_block(1, ipl2, "Cannot read IPL2 record at block 1");
|
||||
|
||||
mbr = &ipl2->mbr;
|
||||
- IPL_assert(magic_match(mbr, ZIPL_MAGIC), "No zIPL section in IPL2 record.");
|
||||
- IPL_assert(block_size_ok(mbr->blockptr.xeckd.bptr.size),
|
||||
- "Bad block size in zIPL section of IPL2 record.");
|
||||
- IPL_assert(mbr->dev_type == DEV_TYPE_ECKD,
|
||||
- "Non-ECKD device type in zIPL section of IPL2 record.");
|
||||
+ if (!magic_match(mbr, ZIPL_MAGIC)) {
|
||||
+ sclp_print("No zIPL section in IPL2 record.\n");
|
||||
+ return;
|
||||
+ }
|
||||
+ if (!block_size_ok(mbr->blockptr.xeckd.bptr.size)) {
|
||||
+ sclp_print("Bad block size in zIPL section of IPL2 record.\n");
|
||||
+ return;
|
||||
+ }
|
||||
+ if (!mbr->dev_type == DEV_TYPE_ECKD) {
|
||||
+ sclp_print("Non-ECKD device type in zIPL section of IPL2 record.\n");
|
||||
+ return;
|
||||
+ }
|
||||
|
||||
/* save pointer to Boot Map Table */
|
||||
bmt_block_nr = eckd_block_num(&mbr->blockptr.xeckd.bptr.chs);
|
||||
@@ -303,10 +310,14 @@ static void ipl_eckd_cdl(void)
|
||||
|
||||
memset(sec, FREE_SPACE_FILLER, sizeof(sec));
|
||||
read_block(2, vlbl, "Cannot read Volume Label at block 2");
|
||||
- IPL_assert(magic_match(vlbl->key, VOL1_MAGIC),
|
||||
- "Invalid magic of volume label block");
|
||||
- IPL_assert(magic_match(vlbl->f.key, VOL1_MAGIC),
|
||||
- "Invalid magic of volser block");
|
||||
+ if (!magic_match(vlbl->key, VOL1_MAGIC)) {
|
||||
+ sclp_print("Invalid magic of volume label block.\n");
|
||||
+ return;
|
||||
+ }
|
||||
+ if (!magic_match(vlbl->f.key, VOL1_MAGIC)) {
|
||||
+ sclp_print("Invalid magic of volser block.\n");
|
||||
+ return;
|
||||
+ }
|
||||
print_volser(vlbl->f.volser);
|
||||
|
||||
run_eckd_boot_script(bmt_block_nr, s1b_block_nr);
|
||||
@@ -400,7 +411,8 @@ static void ipl_eckd(void)
|
||||
read_block(0, mbr, "Cannot read block 0 on DASD");
|
||||
|
||||
if (magic_match(mbr->magic, IPL1_MAGIC)) {
|
||||
- ipl_eckd_cdl(); /* no return */
|
||||
+ ipl_eckd_cdl(); /* only returns in case of error */
|
||||
+ return;
|
||||
}
|
||||
|
||||
/* LDL/CMS? */
|
||||
@@ -827,5 +839,5 @@ void zipl_load(void)
|
||||
panic("\n! Unknown IPL device type !\n");
|
||||
}
|
||||
|
||||
- panic("\n* this can never happen *\n");
|
||||
+ sclp_print("zIPL load failed.\n");
|
||||
}
|
||||
diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c
|
||||
index 5c1c98341d..b5c721c395 100644
|
||||
--- a/pc-bios/s390-ccw/main.c
|
||||
+++ b/pc-bios/s390-ccw/main.c
|
||||
@@ -249,7 +249,7 @@ static void ipl_boot_device(void)
|
||||
break;
|
||||
case CU_TYPE_VIRTIO:
|
||||
if (virtio_setup() == 0) {
|
||||
- zipl_load(); /* no return */
|
||||
+ zipl_load(); /* Only returns in case of errors */
|
||||
}
|
||||
break;
|
||||
default:
|
||||
--
|
||||
2.27.0
|
||||
|
@ -0,0 +1,214 @@
|
||||
From 6f44767aeda52048e7c9ee4b5fcc30353c71cbc1 Mon Sep 17 00:00:00 2001
|
||||
From: Thomas Huth <thuth@redhat.com>
|
||||
Date: Fri, 9 Oct 2020 10:08:45 -0400
|
||||
Subject: [PATCH 09/14] pc-bios/s390-ccw: Do not bail out early if not finding
|
||||
a SCSI disk
|
||||
|
||||
RH-Author: Thomas Huth <thuth@redhat.com>
|
||||
Message-id: <20201009100849.264994-6-thuth@redhat.com>
|
||||
Patchwork-id: 98599
|
||||
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH 5/9] pc-bios/s390-ccw: Do not bail out early if not finding a SCSI disk
|
||||
Bugzilla: 1846975
|
||||
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
|
||||
RH-Acked-by: David Hildenbrand <david@redhat.com>
|
||||
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
||||
|
||||
In case the user did not specify a boot device, we want to continue
|
||||
looking for other devices if there are no valid SCSI disks on a virtio-
|
||||
scsi controller. As a first step, do not panic in this case and let
|
||||
the control flow carry the error to the upper functions instead.
|
||||
|
||||
Message-Id: <20200806105349.632-6-thuth@redhat.com>
|
||||
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
|
||||
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
||||
(cherry picked from commit 605751b5a5334e187761b0b8a8266a216897bf70)
|
||||
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
||||
---
|
||||
pc-bios/s390-ccw/main.c | 14 ++++++++++----
|
||||
pc-bios/s390-ccw/s390-ccw.h | 2 +-
|
||||
pc-bios/s390-ccw/virtio-blkdev.c | 7 +++++--
|
||||
pc-bios/s390-ccw/virtio-scsi.c | 28 ++++++++++++++++++++--------
|
||||
pc-bios/s390-ccw/virtio-scsi.h | 2 +-
|
||||
5 files changed, 37 insertions(+), 16 deletions(-)
|
||||
|
||||
diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c
|
||||
index d6fd218074..456733fbee 100644
|
||||
--- a/pc-bios/s390-ccw/main.c
|
||||
+++ b/pc-bios/s390-ccw/main.c
|
||||
@@ -227,7 +227,7 @@ static void find_boot_device(void)
|
||||
IPL_assert(found, "Boot device not found\n");
|
||||
}
|
||||
|
||||
-static void virtio_setup(void)
|
||||
+static int virtio_setup(void)
|
||||
{
|
||||
VDev *vdev = virtio_get_device();
|
||||
QemuIplParameters *early_qipl = (QemuIplParameters *)QIPL_ADDRESS;
|
||||
@@ -242,9 +242,14 @@ static void virtio_setup(void)
|
||||
sclp_print("Network boot device detected\n");
|
||||
vdev->netboot_start_addr = qipl.netboot_start_addr;
|
||||
} else {
|
||||
- virtio_blk_setup_device(blk_schid);
|
||||
+ int ret = virtio_blk_setup_device(blk_schid);
|
||||
+ if (ret) {
|
||||
+ return ret;
|
||||
+ }
|
||||
IPL_assert(virtio_ipl_disk_is_valid(), "No valid IPL device detected");
|
||||
}
|
||||
+
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
static void ipl_boot_device(void)
|
||||
@@ -255,8 +260,9 @@ static void ipl_boot_device(void)
|
||||
dasd_ipl(blk_schid, cutype); /* no return */
|
||||
break;
|
||||
case CU_TYPE_VIRTIO:
|
||||
- virtio_setup();
|
||||
- zipl_load(); /* no return */
|
||||
+ if (virtio_setup() == 0) {
|
||||
+ zipl_load(); /* no return */
|
||||
+ }
|
||||
break;
|
||||
default:
|
||||
print_int("Attempting to boot from unexpected device type", cutype);
|
||||
diff --git a/pc-bios/s390-ccw/s390-ccw.h b/pc-bios/s390-ccw/s390-ccw.h
|
||||
index ae432c40b8..e7cf36eb91 100644
|
||||
--- a/pc-bios/s390-ccw/s390-ccw.h
|
||||
+++ b/pc-bios/s390-ccw/s390-ccw.h
|
||||
@@ -70,7 +70,7 @@ int sclp_read(char *str, size_t count);
|
||||
unsigned long virtio_load_direct(ulong rec_list1, ulong rec_list2,
|
||||
ulong subchan_id, void *load_addr);
|
||||
bool virtio_is_supported(SubChannelId schid);
|
||||
-void virtio_blk_setup_device(SubChannelId schid);
|
||||
+int virtio_blk_setup_device(SubChannelId schid);
|
||||
int virtio_read(ulong sector, void *load_addr);
|
||||
u64 get_clock(void);
|
||||
ulong get_second(void);
|
||||
diff --git a/pc-bios/s390-ccw/virtio-blkdev.c b/pc-bios/s390-ccw/virtio-blkdev.c
|
||||
index 11c56261ca..7d35050292 100644
|
||||
--- a/pc-bios/s390-ccw/virtio-blkdev.c
|
||||
+++ b/pc-bios/s390-ccw/virtio-blkdev.c
|
||||
@@ -263,9 +263,10 @@ uint64_t virtio_get_blocks(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
-void virtio_blk_setup_device(SubChannelId schid)
|
||||
+int virtio_blk_setup_device(SubChannelId schid)
|
||||
{
|
||||
VDev *vdev = virtio_get_device();
|
||||
+ int ret = 0;
|
||||
|
||||
vdev->schid = schid;
|
||||
virtio_setup_ccw(vdev);
|
||||
@@ -288,9 +289,11 @@ void virtio_blk_setup_device(SubChannelId schid)
|
||||
"Config: CDB size mismatch");
|
||||
|
||||
sclp_print("Using virtio-scsi.\n");
|
||||
- virtio_scsi_setup(vdev);
|
||||
+ ret = virtio_scsi_setup(vdev);
|
||||
break;
|
||||
default:
|
||||
panic("\n! No IPL device available !\n");
|
||||
}
|
||||
+
|
||||
+ return ret;
|
||||
}
|
||||
diff --git a/pc-bios/s390-ccw/virtio-scsi.c b/pc-bios/s390-ccw/virtio-scsi.c
|
||||
index 4fe4b9d261..88691edb89 100644
|
||||
--- a/pc-bios/s390-ccw/virtio-scsi.c
|
||||
+++ b/pc-bios/s390-ccw/virtio-scsi.c
|
||||
@@ -192,7 +192,12 @@ static bool scsi_read_capacity(VDev *vdev,
|
||||
|
||||
/* virtio-scsi routines */
|
||||
|
||||
-static void virtio_scsi_locate_device(VDev *vdev)
|
||||
+/*
|
||||
+ * Tries to locate a SCSI device and and adds the information for the found
|
||||
+ * device to the vdev->scsi_device structure.
|
||||
+ * Returns 0 if SCSI device could be located, or a error code < 0 otherwise
|
||||
+ */
|
||||
+static int virtio_scsi_locate_device(VDev *vdev)
|
||||
{
|
||||
const uint16_t channel = 0; /* again, it's what QEMU does */
|
||||
uint16_t target;
|
||||
@@ -218,7 +223,7 @@ static void virtio_scsi_locate_device(VDev *vdev)
|
||||
IPL_check(sdev->channel == 0, "non-zero channel requested");
|
||||
IPL_check(sdev->target <= vdev->config.scsi.max_target, "target# high");
|
||||
IPL_check(sdev->lun <= vdev->config.scsi.max_lun, "LUN# high");
|
||||
- return;
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
for (target = 0; target <= vdev->config.scsi.max_target; target++) {
|
||||
@@ -245,18 +250,20 @@ static void virtio_scsi_locate_device(VDev *vdev)
|
||||
*/
|
||||
sdev->lun = r->lun[0].v16[0]; /* it's returned this way */
|
||||
debug_print_int("Have to use LUN", sdev->lun);
|
||||
- return; /* we have to use this device */
|
||||
+ return 0; /* we have to use this device */
|
||||
}
|
||||
for (i = 0; i < luns; i++) {
|
||||
if (r->lun[i].v64) {
|
||||
/* Look for non-zero LUN - we have where to choose from */
|
||||
sdev->lun = r->lun[i].v16[0];
|
||||
debug_print_int("Will use LUN", sdev->lun);
|
||||
- return; /* we have found a device */
|
||||
+ return 0; /* we have found a device */
|
||||
}
|
||||
}
|
||||
}
|
||||
- panic("\n! Cannot locate virtio-scsi device !\n");
|
||||
+
|
||||
+ sclp_print("Warning: Could not locate a usable virtio-scsi device\n");
|
||||
+ return -ENODEV;
|
||||
}
|
||||
|
||||
int virtio_scsi_read_many(VDev *vdev,
|
||||
@@ -320,17 +327,20 @@ static void scsi_parse_capacity_report(void *data,
|
||||
}
|
||||
}
|
||||
|
||||
-void virtio_scsi_setup(VDev *vdev)
|
||||
+int virtio_scsi_setup(VDev *vdev)
|
||||
{
|
||||
int retry_test_unit_ready = 3;
|
||||
uint8_t data[256];
|
||||
uint32_t data_size = sizeof(data);
|
||||
ScsiInquiryEvpdPages *evpd = &scsi_inquiry_evpd_pages_response;
|
||||
ScsiInquiryEvpdBl *evpd_bl = &scsi_inquiry_evpd_bl_response;
|
||||
- int i;
|
||||
+ int i, ret;
|
||||
|
||||
vdev->scsi_device = &default_scsi_device;
|
||||
- virtio_scsi_locate_device(vdev);
|
||||
+ ret = virtio_scsi_locate_device(vdev);
|
||||
+ if (ret < 0) {
|
||||
+ return ret;
|
||||
+ }
|
||||
|
||||
/* We have to "ping" the device before it becomes readable */
|
||||
while (!scsi_test_unit_ready(vdev)) {
|
||||
@@ -415,4 +425,6 @@ void virtio_scsi_setup(VDev *vdev)
|
||||
}
|
||||
scsi_parse_capacity_report(data, &vdev->scsi_last_block,
|
||||
(uint32_t *) &vdev->scsi_block_size);
|
||||
+
|
||||
+ return 0;
|
||||
}
|
||||
diff --git a/pc-bios/s390-ccw/virtio-scsi.h b/pc-bios/s390-ccw/virtio-scsi.h
|
||||
index 4c4f4bbc31..4b14c2c2f9 100644
|
||||
--- a/pc-bios/s390-ccw/virtio-scsi.h
|
||||
+++ b/pc-bios/s390-ccw/virtio-scsi.h
|
||||
@@ -67,7 +67,7 @@ static inline bool virtio_scsi_response_ok(const VirtioScsiCmdResp *r)
|
||||
return r->response == VIRTIO_SCSI_S_OK && r->status == CDB_STATUS_GOOD;
|
||||
}
|
||||
|
||||
-void virtio_scsi_setup(VDev *vdev);
|
||||
+int virtio_scsi_setup(VDev *vdev);
|
||||
int virtio_scsi_read_many(VDev *vdev,
|
||||
ulong sector, void *load_addr, int sec_num);
|
||||
|
||||
--
|
||||
2.27.0
|
||||
|
@ -0,0 +1,54 @@
|
||||
From 7b3a7cbfc5872e088f13e11f5c38dc5ac80c3330 Mon Sep 17 00:00:00 2001
|
||||
From: Thomas Huth <thuth@redhat.com>
|
||||
Date: Fri, 9 Oct 2020 10:08:43 -0400
|
||||
Subject: [PATCH 07/14] pc-bios/s390-ccw: Introduce ENODEV define and remove
|
||||
guards of others
|
||||
|
||||
RH-Author: Thomas Huth <thuth@redhat.com>
|
||||
Message-id: <20201009100849.264994-4-thuth@redhat.com>
|
||||
Patchwork-id: 98597
|
||||
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH 3/9] pc-bios/s390-ccw: Introduce ENODEV define and remove guards of others
|
||||
Bugzilla: 1846975
|
||||
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
|
||||
RH-Acked-by: David Hildenbrand <david@redhat.com>
|
||||
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
||||
|
||||
Remove the "#ifndef E..." guards from the defines here - the header
|
||||
guard S390_CCW_H at the top of the file should avoid double definition,
|
||||
and if the error code is defined in a different file already, we're in
|
||||
trouble anyway, then it's better to see the error at compile time instead
|
||||
of hunting weird behavior during runtime later.
|
||||
Also define ENODEV - we will use this in a later patch.
|
||||
|
||||
Message-Id: <20200806105349.632-4-thuth@redhat.com>
|
||||
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
|
||||
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
|
||||
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
||||
(cherry picked from commit f3180b0266386b31deb7bb83fcaea68af7d1bcee)
|
||||
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
||||
---
|
||||
pc-bios/s390-ccw/s390-ccw.h | 6 ++----
|
||||
1 file changed, 2 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/pc-bios/s390-ccw/s390-ccw.h b/pc-bios/s390-ccw/s390-ccw.h
|
||||
index 21f27e7990..ae432c40b8 100644
|
||||
--- a/pc-bios/s390-ccw/s390-ccw.h
|
||||
+++ b/pc-bios/s390-ccw/s390-ccw.h
|
||||
@@ -27,12 +27,10 @@ typedef unsigned long long __u64;
|
||||
#define false 0
|
||||
#define PAGE_SIZE 4096
|
||||
|
||||
-#ifndef EIO
|
||||
#define EIO 1
|
||||
-#endif
|
||||
-#ifndef EBUSY
|
||||
#define EBUSY 2
|
||||
-#endif
|
||||
+#define ENODEV 3
|
||||
+
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
--
|
||||
2.27.0
|
||||
|
@ -0,0 +1,60 @@
|
||||
From eda3b6620e779ff89df46a0fb9022016bffd7f44 Mon Sep 17 00:00:00 2001
|
||||
From: Thomas Huth <thuth@redhat.com>
|
||||
Date: Fri, 9 Oct 2020 10:08:41 -0400
|
||||
Subject: [PATCH 05/14] pc-bios/s390-ccw/Makefile: Compile with -std=gnu99,
|
||||
-fwrapv and -fno-common
|
||||
|
||||
RH-Author: Thomas Huth <thuth@redhat.com>
|
||||
Message-id: <20201009100849.264994-2-thuth@redhat.com>
|
||||
Patchwork-id: 98595
|
||||
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH 1/9] pc-bios/s390-ccw/Makefile: Compile with -std=gnu99, -fwrapv and -fno-common
|
||||
Bugzilla: 1846975
|
||||
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
|
||||
RH-Acked-by: David Hildenbrand <david@redhat.com>
|
||||
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
||||
|
||||
The main QEMU code is compiled with -std=gnu99, -fwrapv and -fno-common.
|
||||
We should use the same flags for the s390-ccw bios, too, to avoid that
|
||||
we get different behavior with different compiler versions that changed
|
||||
their default settings in the course of time (it happened at least with
|
||||
-std=... and -fno-common in the past already).
|
||||
|
||||
While we're at it, also group the other flags here in a little bit nicer
|
||||
fashion: Move the two "-m" flags out of the "-f" area and specify them on
|
||||
a separate line.
|
||||
|
||||
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
|
||||
Acked-by: Cornelia Huck <cohuck@redhat.com>
|
||||
Acked-by: Janosch Frank <frankja@linux.ibm.com>
|
||||
Message-Id: <20200806105349.632-2-thuth@redhat.com>
|
||||
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
||||
(cherry picked from commit 4f6a1eb886961f1f9da2d553c4b0e5ef69cd3801)
|
||||
Conflicts: Simple contextual conflict due to meson reworks in upstream
|
||||
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
||||
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
||||
---
|
||||
pc-bios/s390-ccw/Makefile | 7 ++++---
|
||||
1 file changed, 4 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/pc-bios/s390-ccw/Makefile b/pc-bios/s390-ccw/Makefile
|
||||
index a048b6b077..e776a2a5ec 100644
|
||||
--- a/pc-bios/s390-ccw/Makefile
|
||||
+++ b/pc-bios/s390-ccw/Makefile
|
||||
@@ -13,10 +13,11 @@ OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o \
|
||||
virtio.o virtio-scsi.o virtio-blkdev.o libc.o cio.o dasd-ipl.o
|
||||
|
||||
QEMU_CFLAGS := $(filter -W%, $(QEMU_CFLAGS))
|
||||
-QEMU_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -msoft-float
|
||||
-QEMU_CFLAGS += -march=z900 -fPIE -fno-strict-aliasing
|
||||
-QEMU_CFLAGS += -fno-asynchronous-unwind-tables
|
||||
+QEMU_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -fno-common -fPIE
|
||||
+QEMU_CFLAGS += -fwrapv -fno-strict-aliasing -fno-asynchronous-unwind-tables
|
||||
QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -fno-stack-protector)
|
||||
+QEMU_CFLAGS += -msoft-float -march=z900
|
||||
+QEMU_CFLAGS += -std=gnu99
|
||||
LDFLAGS += -Wl,-pie -nostdlib
|
||||
|
||||
build-all: s390-ccw.img s390-netboot.img
|
||||
--
|
||||
2.27.0
|
||||
|
@ -0,0 +1,72 @@
|
||||
From 740590240bec03dc6ca208963112d3c2999f353e Mon Sep 17 00:00:00 2001
|
||||
From: Thomas Huth <thuth@redhat.com>
|
||||
Date: Fri, 9 Oct 2020 10:08:42 -0400
|
||||
Subject: [PATCH 06/14] pc-bios/s390-ccw: Move ipl-related code from main()
|
||||
into a separate function
|
||||
|
||||
RH-Author: Thomas Huth <thuth@redhat.com>
|
||||
Message-id: <20201009100849.264994-3-thuth@redhat.com>
|
||||
Patchwork-id: 98596
|
||||
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH 2/9] pc-bios/s390-ccw: Move ipl-related code from main() into a separate function
|
||||
Bugzilla: 1846975
|
||||
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
|
||||
RH-Acked-by: David Hildenbrand <david@redhat.com>
|
||||
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
||||
|
||||
Let's move this part of the code into a separate function to be able
|
||||
to use it from multiple spots later.
|
||||
|
||||
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
|
||||
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
|
||||
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
|
||||
Message-Id: <20200806105349.632-3-thuth@redhat.com>
|
||||
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
||||
(cherry picked from commit d1f060a8b515a0b1d14c38f2c8f86ab54e79c3dc)
|
||||
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
||||
---
|
||||
pc-bios/s390-ccw/main.c | 20 ++++++++++++--------
|
||||
1 file changed, 12 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c
|
||||
index 4e65b411e1..5e565be5b1 100644
|
||||
--- a/pc-bios/s390-ccw/main.c
|
||||
+++ b/pc-bios/s390-ccw/main.c
|
||||
@@ -232,14 +232,8 @@ static void virtio_setup(void)
|
||||
}
|
||||
}
|
||||
|
||||
-int main(void)
|
||||
+static void ipl_boot_device(void)
|
||||
{
|
||||
- sclp_setup();
|
||||
- css_setup();
|
||||
- boot_setup();
|
||||
- find_boot_device();
|
||||
- enable_subchannel(blk_schid);
|
||||
-
|
||||
switch (cutype) {
|
||||
case CU_TYPE_DASD_3990:
|
||||
case CU_TYPE_DASD_2107:
|
||||
@@ -251,8 +245,18 @@ int main(void)
|
||||
break;
|
||||
default:
|
||||
print_int("Attempting to boot from unexpected device type", cutype);
|
||||
- panic("");
|
||||
+ panic("\nBoot failed.\n");
|
||||
}
|
||||
+}
|
||||
+
|
||||
+int main(void)
|
||||
+{
|
||||
+ sclp_setup();
|
||||
+ css_setup();
|
||||
+ boot_setup();
|
||||
+ find_boot_device();
|
||||
+ enable_subchannel(blk_schid);
|
||||
+ ipl_boot_device();
|
||||
|
||||
panic("Failed to load OS from hard disk\n");
|
||||
return 0; /* make compiler happy */
|
||||
--
|
||||
2.27.0
|
||||
|
@ -0,0 +1,154 @@
|
||||
From d90cbb55fe3ec232091a24137cab45419aac8bc5 Mon Sep 17 00:00:00 2001
|
||||
From: Thomas Huth <thuth@redhat.com>
|
||||
Date: Fri, 9 Oct 2020 10:08:44 -0400
|
||||
Subject: [PATCH 08/14] pc-bios/s390-ccw: Move the inner logic of find_subch()
|
||||
to a separate function
|
||||
|
||||
RH-Author: Thomas Huth <thuth@redhat.com>
|
||||
Message-id: <20201009100849.264994-5-thuth@redhat.com>
|
||||
Patchwork-id: 98598
|
||||
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH 4/9] pc-bios/s390-ccw: Move the inner logic of find_subch() to a separate function
|
||||
Bugzilla: 1846975
|
||||
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
|
||||
RH-Acked-by: David Hildenbrand <david@redhat.com>
|
||||
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
||||
|
||||
Move the code to a separate function to be able to re-use it from a
|
||||
different spot later.
|
||||
|
||||
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
|
||||
Message-Id: <20200806105349.632-5-thuth@redhat.com>
|
||||
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
|
||||
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
|
||||
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
||||
(cherry picked from commit d2cf4af1f4af02f6f2d5827d9a06c31690084d3b)
|
||||
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
||||
---
|
||||
pc-bios/s390-ccw/main.c | 99 ++++++++++++++++++++++++-----------------
|
||||
1 file changed, 57 insertions(+), 42 deletions(-)
|
||||
|
||||
diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c
|
||||
index 5e565be5b1..d6fd218074 100644
|
||||
--- a/pc-bios/s390-ccw/main.c
|
||||
+++ b/pc-bios/s390-ccw/main.c
|
||||
@@ -60,6 +60,60 @@ unsigned int get_loadparm_index(void)
|
||||
return atoui(loadparm_str);
|
||||
}
|
||||
|
||||
+static int is_dev_possibly_bootable(int dev_no, int sch_no)
|
||||
+{
|
||||
+ bool is_virtio;
|
||||
+ Schib schib;
|
||||
+ int r;
|
||||
+
|
||||
+ blk_schid.sch_no = sch_no;
|
||||
+ r = stsch_err(blk_schid, &schib);
|
||||
+ if (r == 3 || r == -EIO) {
|
||||
+ return -ENODEV;
|
||||
+ }
|
||||
+ if (!schib.pmcw.dnv) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ enable_subchannel(blk_schid);
|
||||
+ cutype = cu_type(blk_schid);
|
||||
+
|
||||
+ /*
|
||||
+ * Note: we always have to run virtio_is_supported() here to make
|
||||
+ * sure that the vdev.senseid data gets pre-initialized correctly
|
||||
+ */
|
||||
+ is_virtio = virtio_is_supported(blk_schid);
|
||||
+
|
||||
+ /* No specific devno given, just return whether the device is possibly bootable */
|
||||
+ if (dev_no < 0) {
|
||||
+ switch (cutype) {
|
||||
+ case CU_TYPE_VIRTIO:
|
||||
+ if (is_virtio) {
|
||||
+ /*
|
||||
+ * Skip net devices since no IPLB is created and therefore
|
||||
+ * no network bootloader has been loaded
|
||||
+ */
|
||||
+ if (virtio_get_device_type() != VIRTIO_ID_NET) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ return false;
|
||||
+ case CU_TYPE_DASD_3990:
|
||||
+ case CU_TYPE_DASD_2107:
|
||||
+ return true;
|
||||
+ default:
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* Caller asked for a specific devno */
|
||||
+ if (schib.pmcw.dev == dev_no) {
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
/*
|
||||
* Find the subchannel connected to the given device (dev_no) and fill in the
|
||||
* subchannel information block (schib) with the connected subchannel's info.
|
||||
@@ -71,53 +125,14 @@ unsigned int get_loadparm_index(void)
|
||||
*/
|
||||
static bool find_subch(int dev_no)
|
||||
{
|
||||
- Schib schib;
|
||||
int i, r;
|
||||
- bool is_virtio;
|
||||
|
||||
for (i = 0; i < 0x10000; i++) {
|
||||
- blk_schid.sch_no = i;
|
||||
- r = stsch_err(blk_schid, &schib);
|
||||
- if ((r == 3) || (r == -EIO)) {
|
||||
+ r = is_dev_possibly_bootable(dev_no, i);
|
||||
+ if (r < 0) {
|
||||
break;
|
||||
}
|
||||
- if (!schib.pmcw.dnv) {
|
||||
- continue;
|
||||
- }
|
||||
-
|
||||
- enable_subchannel(blk_schid);
|
||||
- cutype = cu_type(blk_schid);
|
||||
-
|
||||
- /*
|
||||
- * Note: we always have to run virtio_is_supported() here to make
|
||||
- * sure that the vdev.senseid data gets pre-initialized correctly
|
||||
- */
|
||||
- is_virtio = virtio_is_supported(blk_schid);
|
||||
-
|
||||
- /* No specific devno given, just return 1st possibly bootable device */
|
||||
- if (dev_no < 0) {
|
||||
- switch (cutype) {
|
||||
- case CU_TYPE_VIRTIO:
|
||||
- if (is_virtio) {
|
||||
- /*
|
||||
- * Skip net devices since no IPLB is created and therefore
|
||||
- * no network bootloader has been loaded
|
||||
- */
|
||||
- if (virtio_get_device_type() != VIRTIO_ID_NET) {
|
||||
- return true;
|
||||
- }
|
||||
- }
|
||||
- continue;
|
||||
- case CU_TYPE_DASD_3990:
|
||||
- case CU_TYPE_DASD_2107:
|
||||
- return true;
|
||||
- default:
|
||||
- continue;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- /* Caller asked for a specific devno */
|
||||
- if (schib.pmcw.dev == dev_no) {
|
||||
+ if (r == true) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
--
|
||||
2.27.0
|
||||
|
@ -0,0 +1,116 @@
|
||||
From 911dc631f9ab68c6acfd4b401fbcfaa3b58a4fb6 Mon Sep 17 00:00:00 2001
|
||||
From: Thomas Huth <thuth@redhat.com>
|
||||
Date: Fri, 9 Oct 2020 10:08:46 -0400
|
||||
Subject: [PATCH 10/14] pc-bios/s390-ccw: Scan through all devices if no boot
|
||||
device specified
|
||||
|
||||
RH-Author: Thomas Huth <thuth@redhat.com>
|
||||
Message-id: <20201009100849.264994-7-thuth@redhat.com>
|
||||
Patchwork-id: 98600
|
||||
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH 6/9] pc-bios/s390-ccw: Scan through all devices if no boot device specified
|
||||
Bugzilla: 1846975
|
||||
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
|
||||
RH-Acked-by: David Hildenbrand <david@redhat.com>
|
||||
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
||||
|
||||
If no boot device has been specified (via "bootindex=..."), the s390-ccw
|
||||
bios scans through all devices to find a bootable device. But so far, it
|
||||
stops at the very first block device (including virtio-scsi controllers
|
||||
without attached devices) that it finds, no matter whether it is bootable
|
||||
or not. That leads to some weird situatation where it is e.g. possible
|
||||
to boot via:
|
||||
|
||||
qemu-system-s390x -hda /path/to/disk.qcow2
|
||||
|
||||
but not if there is e.g. a virtio-scsi controller specified before:
|
||||
|
||||
qemu-system-s390x -device virtio-scsi -hda /path/to/disk.qcow2
|
||||
|
||||
While using "bootindex=..." is clearly the preferred way of booting
|
||||
on s390x, we still can make the life for the users at least a little
|
||||
bit easier if we look at all available devices to find a bootable one.
|
||||
|
||||
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1846975
|
||||
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
|
||||
Message-Id: <20200806105349.632-7-thuth@redhat.com>
|
||||
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
||||
(cherry picked from commit 869d0e2f593dd37297c366203f006b9acd1b7b45)
|
||||
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
||||
---
|
||||
pc-bios/s390-ccw/main.c | 46 +++++++++++++++++++++++++++--------------
|
||||
1 file changed, 31 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c
|
||||
index 456733fbee..5c1c98341d 100644
|
||||
--- a/pc-bios/s390-ccw/main.c
|
||||
+++ b/pc-bios/s390-ccw/main.c
|
||||
@@ -191,20 +191,8 @@ static void boot_setup(void)
|
||||
static void find_boot_device(void)
|
||||
{
|
||||
VDev *vdev = virtio_get_device();
|
||||
- int ssid;
|
||||
bool found;
|
||||
|
||||
- if (!have_iplb) {
|
||||
- for (ssid = 0; ssid < 0x3; ssid++) {
|
||||
- blk_schid.ssid = ssid;
|
||||
- found = find_subch(-1);
|
||||
- if (found) {
|
||||
- return;
|
||||
- }
|
||||
- }
|
||||
- panic("Could not find a suitable boot device (none specified)\n");
|
||||
- }
|
||||
-
|
||||
switch (iplb.pbt) {
|
||||
case S390_IPL_TYPE_CCW:
|
||||
debug_print_int("device no. ", iplb.ccw.devno);
|
||||
@@ -270,14 +258,42 @@ static void ipl_boot_device(void)
|
||||
}
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * No boot device has been specified, so we have to scan through the
|
||||
+ * channels to find one.
|
||||
+ */
|
||||
+static void probe_boot_device(void)
|
||||
+{
|
||||
+ int ssid, sch_no, ret;
|
||||
+
|
||||
+ for (ssid = 0; ssid < 0x3; ssid++) {
|
||||
+ blk_schid.ssid = ssid;
|
||||
+ for (sch_no = 0; sch_no < 0x10000; sch_no++) {
|
||||
+ ret = is_dev_possibly_bootable(-1, sch_no);
|
||||
+ if (ret < 0) {
|
||||
+ break;
|
||||
+ }
|
||||
+ if (ret == true) {
|
||||
+ ipl_boot_device(); /* Only returns if unsuccessful */
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ sclp_print("Could not find a suitable boot device (none specified)\n");
|
||||
+}
|
||||
+
|
||||
int main(void)
|
||||
{
|
||||
sclp_setup();
|
||||
css_setup();
|
||||
boot_setup();
|
||||
- find_boot_device();
|
||||
- enable_subchannel(blk_schid);
|
||||
- ipl_boot_device();
|
||||
+ if (have_iplb) {
|
||||
+ find_boot_device();
|
||||
+ enable_subchannel(blk_schid);
|
||||
+ ipl_boot_device();
|
||||
+ } else {
|
||||
+ probe_boot_device();
|
||||
+ }
|
||||
|
||||
panic("Failed to load OS from hard disk\n");
|
||||
return 0; /* make compiler happy */
|
||||
--
|
||||
2.27.0
|
||||
|
@ -0,0 +1,43 @@
|
||||
From 541d06b7dc1cd3ad4722850f3a7f5df12b8d6fba Mon Sep 17 00:00:00 2001
|
||||
From: Thomas Huth <thuth@redhat.com>
|
||||
Date: Fri, 9 Oct 2020 10:08:48 -0400
|
||||
Subject: [PATCH 12/14] pc-bios/s390-ccw/main: Remove superfluous call to
|
||||
enable_subchannel()
|
||||
|
||||
RH-Author: Thomas Huth <thuth@redhat.com>
|
||||
Message-id: <20201009100849.264994-9-thuth@redhat.com>
|
||||
Patchwork-id: 98602
|
||||
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH 8/9] pc-bios/s390-ccw/main: Remove superfluous call to enable_subchannel()
|
||||
Bugzilla: 1846975
|
||||
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
|
||||
RH-Acked-by: David Hildenbrand <david@redhat.com>
|
||||
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
||||
|
||||
enable_subchannel() is already done during is_dev_possibly_bootable()
|
||||
(which is called from find_boot_device() -> find_subch()), so there
|
||||
is no need to do this again in the main() function.
|
||||
|
||||
Message-Id: <20200806105349.632-9-thuth@redhat.com>
|
||||
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
|
||||
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
||||
(cherry picked from commit 49d4388ec03fd8c7701b907a4e11c437a28f8572)
|
||||
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
||||
---
|
||||
pc-bios/s390-ccw/main.c | 1 -
|
||||
1 file changed, 1 deletion(-)
|
||||
|
||||
diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c
|
||||
index b5c721c395..e3a1a3053d 100644
|
||||
--- a/pc-bios/s390-ccw/main.c
|
||||
+++ b/pc-bios/s390-ccw/main.c
|
||||
@@ -289,7 +289,6 @@ int main(void)
|
||||
boot_setup();
|
||||
if (have_iplb) {
|
||||
find_boot_device();
|
||||
- enable_subchannel(blk_schid);
|
||||
ipl_boot_device();
|
||||
} else {
|
||||
probe_boot_device();
|
||||
--
|
||||
2.27.0
|
||||
|
@ -0,0 +1,140 @@
|
||||
From 3a63e2d29bb2fd92577d42aeb8fa956ae18df22e Mon Sep 17 00:00:00 2001
|
||||
From: Thomas Huth <thuth@redhat.com>
|
||||
Date: Fri, 2 Oct 2020 10:17:41 -0400
|
||||
Subject: [PATCH 02/14] qga/commands-posix: Move the udev code from the pci to
|
||||
the generic function
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
RH-Author: Thomas Huth <thuth@redhat.com>
|
||||
Message-id: <20201002101742.249169-3-thuth@redhat.com>
|
||||
Patchwork-id: 98526
|
||||
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH 2/3] qga/commands-posix: Move the udev code from the pci to the generic function
|
||||
Bugzilla: 1755075
|
||||
RH-Acked-by: Danilo de Paula <ddepaula@redhat.com>
|
||||
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
||||
RH-Acked-by: David Hildenbrand <david@redhat.com>
|
||||
|
||||
The libudev-related code is independent from the other pci-related code
|
||||
and can be re-used for non-pci devices (like ccw devices on s390x). Thus
|
||||
move this part to the generic function.
|
||||
|
||||
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1755075
|
||||
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
||||
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
|
||||
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
|
||||
(cherry picked from commit 43dadc431bacbc5a5baee7e256288a98a3e95ce3)
|
||||
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
||||
---
|
||||
qga/commands-posix.c | 62 +++++++++++++++++++++++---------------------
|
||||
1 file changed, 33 insertions(+), 29 deletions(-)
|
||||
|
||||
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
|
||||
index 99d6b1c8c1..6db76aadd1 100644
|
||||
--- a/qga/commands-posix.c
|
||||
+++ b/qga/commands-posix.c
|
||||
@@ -878,10 +878,6 @@ static bool build_guest_fsinfo_for_pci_dev(char const *syspath,
|
||||
GuestPCIAddress *pciaddr = disk->pci_controller;
|
||||
bool has_ata = false, has_host = false, has_tgt = false;
|
||||
char *p, *q, *driver = NULL;
|
||||
-#ifdef CONFIG_LIBUDEV
|
||||
- struct udev *udev = NULL;
|
||||
- struct udev_device *udevice = NULL;
|
||||
-#endif
|
||||
bool ret = false;
|
||||
|
||||
p = strstr(syspath, "/devices/pci");
|
||||
@@ -940,26 +936,6 @@ static bool build_guest_fsinfo_for_pci_dev(char const *syspath,
|
||||
pciaddr->slot = pci[2];
|
||||
pciaddr->function = pci[3];
|
||||
|
||||
-#ifdef CONFIG_LIBUDEV
|
||||
- udev = udev_new();
|
||||
- udevice = udev_device_new_from_syspath(udev, syspath);
|
||||
- if (udev == NULL || udevice == NULL) {
|
||||
- g_debug("failed to query udev");
|
||||
- } else {
|
||||
- const char *devnode, *serial;
|
||||
- devnode = udev_device_get_devnode(udevice);
|
||||
- if (devnode != NULL) {
|
||||
- disk->dev = g_strdup(devnode);
|
||||
- disk->has_dev = true;
|
||||
- }
|
||||
- serial = udev_device_get_property_value(udevice, "ID_SERIAL");
|
||||
- if (serial != NULL && *serial != 0) {
|
||||
- disk->serial = g_strdup(serial);
|
||||
- disk->has_serial = true;
|
||||
- }
|
||||
- }
|
||||
-#endif
|
||||
-
|
||||
if (strcmp(driver, "ata_piix") == 0) {
|
||||
/* a host per ide bus, target*:0:<unit>:0 */
|
||||
if (!has_host || !has_tgt) {
|
||||
@@ -1021,10 +997,6 @@ static bool build_guest_fsinfo_for_pci_dev(char const *syspath,
|
||||
|
||||
cleanup:
|
||||
g_free(driver);
|
||||
-#ifdef CONFIG_LIBUDEV
|
||||
- udev_unref(udev);
|
||||
- udev_device_unref(udevice);
|
||||
-#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1037,18 +1009,50 @@ static void build_guest_fsinfo_for_real_device(char const *syspath,
|
||||
GuestPCIAddress *pciaddr;
|
||||
GuestDiskAddressList *list = NULL;
|
||||
bool has_hwinf;
|
||||
+#ifdef CONFIG_LIBUDEV
|
||||
+ struct udev *udev = NULL;
|
||||
+ struct udev_device *udevice = NULL;
|
||||
+#endif
|
||||
|
||||
pciaddr = g_new0(GuestPCIAddress, 1);
|
||||
+ pciaddr->domain = -1; /* -1 means field is invalid */
|
||||
+ pciaddr->bus = -1;
|
||||
+ pciaddr->slot = -1;
|
||||
+ pciaddr->function = -1;
|
||||
|
||||
disk = g_new0(GuestDiskAddress, 1);
|
||||
disk->pci_controller = pciaddr;
|
||||
+ disk->bus_type = GUEST_DISK_BUS_TYPE_UNKNOWN;
|
||||
|
||||
list = g_new0(GuestDiskAddressList, 1);
|
||||
list->value = disk;
|
||||
|
||||
+#ifdef CONFIG_LIBUDEV
|
||||
+ udev = udev_new();
|
||||
+ udevice = udev_device_new_from_syspath(udev, syspath);
|
||||
+ if (udev == NULL || udevice == NULL) {
|
||||
+ g_debug("failed to query udev");
|
||||
+ } else {
|
||||
+ const char *devnode, *serial;
|
||||
+ devnode = udev_device_get_devnode(udevice);
|
||||
+ if (devnode != NULL) {
|
||||
+ disk->dev = g_strdup(devnode);
|
||||
+ disk->has_dev = true;
|
||||
+ }
|
||||
+ serial = udev_device_get_property_value(udevice, "ID_SERIAL");
|
||||
+ if (serial != NULL && *serial != 0) {
|
||||
+ disk->serial = g_strdup(serial);
|
||||
+ disk->has_serial = true;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ udev_unref(udev);
|
||||
+ udev_device_unref(udevice);
|
||||
+#endif
|
||||
+
|
||||
has_hwinf = build_guest_fsinfo_for_pci_dev(syspath, disk, errp);
|
||||
|
||||
- if (has_hwinf) {
|
||||
+ if (has_hwinf || disk->has_dev || disk->has_serial) {
|
||||
list->next = fs->disk;
|
||||
fs->disk = list;
|
||||
} else {
|
||||
--
|
||||
2.27.0
|
||||
|
@ -0,0 +1,156 @@
|
||||
From 84bc86fdf47729bca77957a04161862ffbedbf2f Mon Sep 17 00:00:00 2001
|
||||
From: Thomas Huth <thuth@redhat.com>
|
||||
Date: Fri, 2 Oct 2020 10:17:40 -0400
|
||||
Subject: [PATCH 01/14] qga/commands-posix: Rework
|
||||
build_guest_fsinfo_for_real_device() function
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Message-id: <20201002101742.249169-2-thuth@redhat.com>
|
||||
Patchwork-id: 98527
|
||||
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH 1/3] qga/commands-posix: Rework build_guest_fsinfo_for_real_device() function
|
||||
Bugzilla: 1755075
|
||||
RH-Acked-by: Danilo de Paula <ddepaula@redhat.com>
|
||||
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
||||
RH-Acked-by: David Hildenbrand <david@redhat.com>
|
||||
|
||||
We are going to support non-PCI devices soon. For this we need to split
|
||||
the generic GuestDiskAddress and GuestDiskAddressList memory allocation
|
||||
and list chaining into a separate function first.
|
||||
|
||||
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
||||
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
|
||||
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
|
||||
(cherry picked from commit d9fe4f0fea31f0560dc40d3576bc6c48ad97109f)
|
||||
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
||||
---
|
||||
qga/commands-posix.c | 65 ++++++++++++++++++++++++++++----------------
|
||||
1 file changed, 41 insertions(+), 24 deletions(-)
|
||||
|
||||
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
|
||||
index 1c1a165dae..99d6b1c8c1 100644
|
||||
--- a/qga/commands-posix.c
|
||||
+++ b/qga/commands-posix.c
|
||||
@@ -865,28 +865,30 @@ static int build_hosts(char const *syspath, char const *host, bool ata,
|
||||
return i;
|
||||
}
|
||||
|
||||
-/* Store disk device info specified by @sysfs into @fs */
|
||||
-static void build_guest_fsinfo_for_real_device(char const *syspath,
|
||||
- GuestFilesystemInfo *fs,
|
||||
- Error **errp)
|
||||
+/*
|
||||
+ * Store disk device info for devices on the PCI bus.
|
||||
+ * Returns true if information has been stored, or false for failure.
|
||||
+ */
|
||||
+static bool build_guest_fsinfo_for_pci_dev(char const *syspath,
|
||||
+ GuestDiskAddress *disk,
|
||||
+ Error **errp)
|
||||
{
|
||||
unsigned int pci[4], host, hosts[8], tgt[3];
|
||||
int i, nhosts = 0, pcilen;
|
||||
- GuestDiskAddress *disk;
|
||||
- GuestPCIAddress *pciaddr;
|
||||
- GuestDiskAddressList *list = NULL;
|
||||
+ GuestPCIAddress *pciaddr = disk->pci_controller;
|
||||
bool has_ata = false, has_host = false, has_tgt = false;
|
||||
char *p, *q, *driver = NULL;
|
||||
#ifdef CONFIG_LIBUDEV
|
||||
struct udev *udev = NULL;
|
||||
struct udev_device *udevice = NULL;
|
||||
#endif
|
||||
+ bool ret = false;
|
||||
|
||||
p = strstr(syspath, "/devices/pci");
|
||||
if (!p || sscanf(p + 12, "%*x:%*x/%x:%x:%x.%x%n",
|
||||
pci, pci + 1, pci + 2, pci + 3, &pcilen) < 4) {
|
||||
g_debug("only pci device is supported: sysfs path '%s'", syspath);
|
||||
- return;
|
||||
+ return false;
|
||||
}
|
||||
|
||||
p += 12 + pcilen;
|
||||
@@ -907,7 +909,7 @@ static void build_guest_fsinfo_for_real_device(char const *syspath,
|
||||
}
|
||||
|
||||
g_debug("unsupported driver or sysfs path '%s'", syspath);
|
||||
- return;
|
||||
+ return false;
|
||||
}
|
||||
|
||||
p = strstr(syspath, "/target");
|
||||
@@ -933,18 +935,11 @@ static void build_guest_fsinfo_for_real_device(char const *syspath,
|
||||
}
|
||||
}
|
||||
|
||||
- pciaddr = g_malloc0(sizeof(*pciaddr));
|
||||
pciaddr->domain = pci[0];
|
||||
pciaddr->bus = pci[1];
|
||||
pciaddr->slot = pci[2];
|
||||
pciaddr->function = pci[3];
|
||||
|
||||
- disk = g_malloc0(sizeof(*disk));
|
||||
- disk->pci_controller = pciaddr;
|
||||
-
|
||||
- list = g_malloc0(sizeof(*list));
|
||||
- list->value = disk;
|
||||
-
|
||||
#ifdef CONFIG_LIBUDEV
|
||||
udev = udev_new();
|
||||
udevice = udev_device_new_from_syspath(udev, syspath);
|
||||
@@ -1022,21 +1017,43 @@ static void build_guest_fsinfo_for_real_device(char const *syspath,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
- list->next = fs->disk;
|
||||
- fs->disk = list;
|
||||
- goto out;
|
||||
+ ret = true;
|
||||
|
||||
cleanup:
|
||||
- if (list) {
|
||||
- qapi_free_GuestDiskAddressList(list);
|
||||
- }
|
||||
-out:
|
||||
g_free(driver);
|
||||
#ifdef CONFIG_LIBUDEV
|
||||
udev_unref(udev);
|
||||
udev_device_unref(udevice);
|
||||
#endif
|
||||
- return;
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+/* Store disk device info specified by @sysfs into @fs */
|
||||
+static void build_guest_fsinfo_for_real_device(char const *syspath,
|
||||
+ GuestFilesystemInfo *fs,
|
||||
+ Error **errp)
|
||||
+{
|
||||
+ GuestDiskAddress *disk;
|
||||
+ GuestPCIAddress *pciaddr;
|
||||
+ GuestDiskAddressList *list = NULL;
|
||||
+ bool has_hwinf;
|
||||
+
|
||||
+ pciaddr = g_new0(GuestPCIAddress, 1);
|
||||
+
|
||||
+ disk = g_new0(GuestDiskAddress, 1);
|
||||
+ disk->pci_controller = pciaddr;
|
||||
+
|
||||
+ list = g_new0(GuestDiskAddressList, 1);
|
||||
+ list->value = disk;
|
||||
+
|
||||
+ has_hwinf = build_guest_fsinfo_for_pci_dev(syspath, disk, errp);
|
||||
+
|
||||
+ if (has_hwinf) {
|
||||
+ list->next = fs->disk;
|
||||
+ fs->disk = list;
|
||||
+ } else {
|
||||
+ qapi_free_GuestDiskAddressList(list);
|
||||
+ }
|
||||
}
|
||||
|
||||
static void build_guest_fsinfo_for_device(char const *devpath,
|
||||
--
|
||||
2.27.0
|
||||
|
@ -0,0 +1,94 @@
|
||||
From 250227a53c1d43d2bd8346922edb3452f3534be6 Mon Sep 17 00:00:00 2001
|
||||
From: Thomas Huth <thuth@redhat.com>
|
||||
Date: Fri, 2 Oct 2020 10:17:42 -0400
|
||||
Subject: [PATCH 03/14] qga/commands-posix: Support fsinfo for non-PCI virtio
|
||||
devices, too
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
RH-Author: Thomas Huth <thuth@redhat.com>
|
||||
Message-id: <20201002101742.249169-4-thuth@redhat.com>
|
||||
Patchwork-id: 98528
|
||||
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH 3/3] qga/commands-posix: Support fsinfo for non-PCI virtio devices, too
|
||||
Bugzilla: 1755075
|
||||
RH-Acked-by: Danilo de Paula <ddepaula@redhat.com>
|
||||
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
||||
RH-Acked-by: David Hildenbrand <david@redhat.com>
|
||||
|
||||
QEMU on s390x uses virtio via channel I/O instead of PCI by default.
|
||||
Add a function to detect and provide information for virtio-scsi and
|
||||
virtio-block devices here, too.
|
||||
|
||||
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
||||
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
|
||||
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
|
||||
(cherry picked from commit 23843c129d5e1ca360605e511a43a34faebb47c4)
|
||||
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
||||
---
|
||||
qga/commands-posix.c | 42 +++++++++++++++++++++++++++++++++++++++++-
|
||||
1 file changed, 41 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
|
||||
index 6db76aadd1..c86c87ed52 100644
|
||||
--- a/qga/commands-posix.c
|
||||
+++ b/qga/commands-posix.c
|
||||
@@ -1000,6 +1000,39 @@ cleanup:
|
||||
return ret;
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * Store disk device info for non-PCI virtio devices (for example s390x
|
||||
+ * channel I/O devices). Returns true if information has been stored, or
|
||||
+ * false for failure.
|
||||
+ */
|
||||
+static bool build_guest_fsinfo_for_nonpci_virtio(char const *syspath,
|
||||
+ GuestDiskAddress *disk,
|
||||
+ Error **errp)
|
||||
+{
|
||||
+ unsigned int tgt[3];
|
||||
+ char *p;
|
||||
+
|
||||
+ if (!strstr(syspath, "/virtio") || !strstr(syspath, "/block")) {
|
||||
+ g_debug("Unsupported virtio device '%s'", syspath);
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ p = strstr(syspath, "/target");
|
||||
+ if (p && sscanf(p + 7, "%*u:%*u:%*u/%*u:%u:%u:%u",
|
||||
+ &tgt[0], &tgt[1], &tgt[2]) == 3) {
|
||||
+ /* virtio-scsi: target*:0:<target>:<unit> */
|
||||
+ disk->bus_type = GUEST_DISK_BUS_TYPE_SCSI;
|
||||
+ disk->bus = tgt[0];
|
||||
+ disk->target = tgt[1];
|
||||
+ disk->unit = tgt[2];
|
||||
+ } else {
|
||||
+ /* virtio-blk: 1 disk per 1 device */
|
||||
+ disk->bus_type = GUEST_DISK_BUS_TYPE_VIRTIO;
|
||||
+ }
|
||||
+
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
/* Store disk device info specified by @sysfs into @fs */
|
||||
static void build_guest_fsinfo_for_real_device(char const *syspath,
|
||||
GuestFilesystemInfo *fs,
|
||||
@@ -1050,7 +1083,14 @@ static void build_guest_fsinfo_for_real_device(char const *syspath,
|
||||
udev_device_unref(udevice);
|
||||
#endif
|
||||
|
||||
- has_hwinf = build_guest_fsinfo_for_pci_dev(syspath, disk, errp);
|
||||
+ if (strstr(syspath, "/devices/pci")) {
|
||||
+ has_hwinf = build_guest_fsinfo_for_pci_dev(syspath, disk, errp);
|
||||
+ } else if (strstr(syspath, "/virtio")) {
|
||||
+ has_hwinf = build_guest_fsinfo_for_nonpci_virtio(syspath, disk, errp);
|
||||
+ } else {
|
||||
+ g_debug("Unsupported device type for '%s'", syspath);
|
||||
+ has_hwinf = false;
|
||||
+ }
|
||||
|
||||
if (has_hwinf || disk->has_dev || disk->has_serial) {
|
||||
list->next = fs->disk;
|
||||
--
|
||||
2.27.0
|
||||
|
@ -67,7 +67,7 @@ Obsoletes: %1-rhev
|
||||
Summary: QEMU is a machine emulator and virtualizer
|
||||
Name: qemu-kvm
|
||||
Version: 4.2.0
|
||||
Release: 34%{?dist}
|
||||
Release: 35%{?dist}
|
||||
# Epoch because we pushed a qemu-1.0 package. AIUI this can't ever be dropped
|
||||
Epoch: 15
|
||||
License: GPLv2 and GPLv2+ and CC-BY
|
||||
@ -938,6 +938,32 @@ Patch390: kvm-target-i386-sev-fail-query-sev-capabilities-if-QEMU-.patch
|
||||
Patch391: kvm-s390x-protvirt-allow-to-IPL-secure-guests-with-no-re.patch
|
||||
# For bz#1869710 - CVE-2020-14364 qemu-kvm: QEMU: usb: out-of-bounds r/w access issue while processing usb packets [rhel-8.3.0]
|
||||
Patch392: kvm-usb-fix-setup_len-init-CVE-2020-14364.patch
|
||||
# For bz#1755075 - [qemu-guest-agent] fsinfo doesn't return disk info on s390x
|
||||
Patch393: kvm-qga-commands-posix-Rework-build_guest_fsinfo_for_rea.patch
|
||||
# For bz#1755075 - [qemu-guest-agent] fsinfo doesn't return disk info on s390x
|
||||
Patch394: kvm-qga-commands-posix-Move-the-udev-code-from-the-pci-t.patch
|
||||
# For bz#1755075 - [qemu-guest-agent] fsinfo doesn't return disk info on s390x
|
||||
Patch395: kvm-qga-commands-posix-Support-fsinfo-for-non-PCI-virtio.patch
|
||||
# For bz#1874780 - -prom-env does not validate input
|
||||
Patch396: kvm-nvram-Exit-QEMU-if-NVRAM-cannot-contain-all-prom-env.patch
|
||||
# For bz#1846975 - Failed to boot up a s390x guest with virtio-blk-ccw if attaching a virtio-scsi-ccw bus in previous
|
||||
Patch397: kvm-pc-bios-s390-ccw-Makefile-Compile-with-std-gnu99-fwr.patch
|
||||
# For bz#1846975 - Failed to boot up a s390x guest with virtio-blk-ccw if attaching a virtio-scsi-ccw bus in previous
|
||||
Patch398: kvm-pc-bios-s390-ccw-Move-ipl-related-code-from-main-int.patch
|
||||
# For bz#1846975 - Failed to boot up a s390x guest with virtio-blk-ccw if attaching a virtio-scsi-ccw bus in previous
|
||||
Patch399: kvm-pc-bios-s390-ccw-Introduce-ENODEV-define-and-remove-.patch
|
||||
# For bz#1846975 - Failed to boot up a s390x guest with virtio-blk-ccw if attaching a virtio-scsi-ccw bus in previous
|
||||
Patch400: kvm-pc-bios-s390-ccw-Move-the-inner-logic-of-find_subch-.patch
|
||||
# For bz#1846975 - Failed to boot up a s390x guest with virtio-blk-ccw if attaching a virtio-scsi-ccw bus in previous
|
||||
Patch401: kvm-pc-bios-s390-ccw-Do-not-bail-out-early-if-not-findin.patch
|
||||
# For bz#1846975 - Failed to boot up a s390x guest with virtio-blk-ccw if attaching a virtio-scsi-ccw bus in previous
|
||||
Patch402: kvm-pc-bios-s390-ccw-Scan-through-all-devices-if-no-boot.patch
|
||||
# For bz#1846975 - Failed to boot up a s390x guest with virtio-blk-ccw if attaching a virtio-scsi-ccw bus in previous
|
||||
Patch403: kvm-pc-bios-s390-ccw-Allow-booting-in-case-the-first-vir.patch
|
||||
# For bz#1846975 - Failed to boot up a s390x guest with virtio-blk-ccw if attaching a virtio-scsi-ccw bus in previous
|
||||
Patch404: kvm-pc-bios-s390-ccw-main-Remove-superfluous-call-to-ena.patch
|
||||
# For bz#1846975 - Failed to boot up a s390x guest with virtio-blk-ccw if attaching a virtio-scsi-ccw bus in previous
|
||||
Patch405: kvm-aio-posix-completely-stop-polling-when-disabled.patch
|
||||
|
||||
BuildRequires: wget
|
||||
BuildRequires: rpm-build
|
||||
@ -975,7 +1001,7 @@ BuildRequires: librados-devel
|
||||
BuildRequires: librbd-devel
|
||||
%if %{have_gluster}
|
||||
# For gluster block driver
|
||||
BuildRequires: glusterfs-api-devel >= 3.6.0
|
||||
BuildRequires: glusterfs-api-devel
|
||||
BuildRequires: glusterfs-devel
|
||||
%endif
|
||||
# We need both because the 'stap' binary is probed for by configure
|
||||
@ -1087,9 +1113,6 @@ Requires: %{name}-common = %{epoch}:%{version}-%{release}
|
||||
Requires: libseccomp >= 2.4.0
|
||||
# For compressed guest memory dumps
|
||||
Requires: lzo snappy
|
||||
%if %{have_gluster}
|
||||
Requires: glusterfs-api >= 3.6.0
|
||||
%endif
|
||||
%if %{have_kvm_setup}
|
||||
Requires(post): systemd-units
|
||||
Requires(preun): systemd-units
|
||||
@ -1873,6 +1896,30 @@ useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin \
|
||||
|
||||
|
||||
%changelog
|
||||
* Mon Oct 19 2020 Danilo Cesar Lemes de Paula <ddepaula@redhat.com> - 4.2.0-35.el8
|
||||
- kvm-qga-commands-posix-Rework-build_guest_fsinfo_for_rea.patch [bz#1755075]
|
||||
- kvm-qga-commands-posix-Move-the-udev-code-from-the-pci-t.patch [bz#1755075]
|
||||
- kvm-qga-commands-posix-Support-fsinfo-for-non-PCI-virtio.patch [bz#1755075]
|
||||
- kvm-nvram-Exit-QEMU-if-NVRAM-cannot-contain-all-prom-env.patch [bz#1874780]
|
||||
- kvm-pc-bios-s390-ccw-Makefile-Compile-with-std-gnu99-fwr.patch [bz#1846975]
|
||||
- kvm-pc-bios-s390-ccw-Move-ipl-related-code-from-main-int.patch [bz#1846975]
|
||||
- kvm-pc-bios-s390-ccw-Introduce-ENODEV-define-and-remove-.patch [bz#1846975]
|
||||
- kvm-pc-bios-s390-ccw-Move-the-inner-logic-of-find_subch-.patch [bz#1846975]
|
||||
- kvm-pc-bios-s390-ccw-Do-not-bail-out-early-if-not-findin.patch [bz#1846975]
|
||||
- kvm-pc-bios-s390-ccw-Scan-through-all-devices-if-no-boot.patch [bz#1846975]
|
||||
- kvm-pc-bios-s390-ccw-Allow-booting-in-case-the-first-vir.patch [bz#1846975]
|
||||
- kvm-pc-bios-s390-ccw-main-Remove-superfluous-call-to-ena.patch [bz#1846975]
|
||||
- kvm-aio-posix-completely-stop-polling-when-disabled.patch [bz#1846975]
|
||||
- kvm-Remove-explicit-glusterfs-api-dependency.patch [bz#1872854]
|
||||
- Resolves: bz#1755075
|
||||
([qemu-guest-agent] fsinfo doesn't return disk info on s390x)
|
||||
- Resolves: bz#1846975
|
||||
(Failed to boot up a s390x guest with virtio-blk-ccw if attaching a virtio-scsi-ccw bus in previous)
|
||||
- Resolves: bz#1872854
|
||||
(move the glusterfs dependency out of qemu-kvm-core to the glusterfs module)
|
||||
- Resolves: bz#1874780
|
||||
(-prom-env does not validate input)
|
||||
|
||||
* Tue Sep 08 2020 Danilo Cesar Lemes de Paula <ddepaula@redhat.com> - 4.2.0-34.el8
|
||||
- kvm-usb-fix-setup_len-init-CVE-2020-14364.patch [bz#1869710]
|
||||
- Resolves: bz#1869710
|
||||
|
Loading…
Reference in New Issue
Block a user