* [PATCH 0/2] Fix runqemu startup failure
@ 2017-08-18 10:19 Chen Qi
2017-08-18 10:19 ` [PATCH 1/2] qemu: backport patches to fix boot failure Chen Qi
2017-08-18 10:19 ` [PATCH 2/2] qemu conf: replace deprecated option with new option Chen Qi
0 siblings, 2 replies; 3+ messages in thread
From: Chen Qi @ 2017-08-18 10:19 UTC (permalink / raw)
To: openembedded-core
The following changes since commit 55bf88603927469de9aa9f6fd4d449230d2e61e3:
poky: Add nios2 to list of qemu targets (2017-08-17 00:21:35 +0100)
are available in the git repository at:
git://git.pokylinux.org/poky-contrib ChenQi/runqemu_boot_error
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=ChenQi/runqemu_boot_error
Chen Qi (2):
qemu: backport patches to fix boot failure
qemu conf: replace deprecated option with new option
meta/conf/machine/include/qemuboot-mips.inc | 2 +-
meta/conf/machine/include/qemuboot-x86.inc | 2 +-
meta/conf/machine/qemuarm.conf | 2 +-
meta/conf/machine/qemuppc.conf | 2 +-
...0001-osdep-Add-runtime-OFD-lock-detection.patch | 141 +++++++++++++++++++++
...e-posix-Do-runtime-check-for-ofd-lock-API.patch | 71 +++++++++++
meta/recipes-devtools/qemu/qemu_2.10.0-rc2.bb | 2 +
7 files changed, 218 insertions(+), 4 deletions(-)
create mode 100644 meta/recipes-devtools/qemu/qemu/0001-osdep-Add-runtime-OFD-lock-detection.patch
create mode 100644 meta/recipes-devtools/qemu/qemu/0002-file-posix-Do-runtime-check-for-ofd-lock-API.patch
--
1.9.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] qemu: backport patches to fix boot failure
2017-08-18 10:19 [PATCH 0/2] Fix runqemu startup failure Chen Qi
@ 2017-08-18 10:19 ` Chen Qi
2017-08-18 10:19 ` [PATCH 2/2] qemu conf: replace deprecated option with new option Chen Qi
1 sibling, 0 replies; 3+ messages in thread
From: Chen Qi @ 2017-08-18 10:19 UTC (permalink / raw)
To: openembedded-core
Backport two patches to fix the following error when booting qemu.
Failed to unlock byte 100
Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
...0001-osdep-Add-runtime-OFD-lock-detection.patch | 141 +++++++++++++++++++++
...e-posix-Do-runtime-check-for-ofd-lock-API.patch | 71 +++++++++++
meta/recipes-devtools/qemu/qemu_2.10.0-rc2.bb | 2 +
3 files changed, 214 insertions(+)
create mode 100644 meta/recipes-devtools/qemu/qemu/0001-osdep-Add-runtime-OFD-lock-detection.patch
create mode 100644 meta/recipes-devtools/qemu/qemu/0002-file-posix-Do-runtime-check-for-ofd-lock-API.patch
diff --git a/meta/recipes-devtools/qemu/qemu/0001-osdep-Add-runtime-OFD-lock-detection.patch b/meta/recipes-devtools/qemu/qemu/0001-osdep-Add-runtime-OFD-lock-detection.patch
new file mode 100644
index 0000000..f83f0d2
--- /dev/null
+++ b/meta/recipes-devtools/qemu/qemu/0001-osdep-Add-runtime-OFD-lock-detection.patch
@@ -0,0 +1,141 @@
+From ca749954b09b89e22cd69c4949fb7e689b057963 Mon Sep 17 00:00:00 2001
+From: Fam Zheng <famz@redhat.com>
+Date: Fri, 11 Aug 2017 19:44:46 +0800
+Subject: [PATCH 1/2] osdep: Add runtime OFD lock detection
+
+Build time check of OFD lock is not sufficient and can cause image open
+errors when the runtime environment doesn't support it.
+
+Add a helper function to probe it at runtime, additionally. Also provide
+a qemu_has_ofd_lock() for callers to check the status.
+
+Signed-off-by: Fam Zheng <famz@redhat.com>
+Signed-off-by: Kevin Wolf <kwolf@redhat.com>
+
+Upstream-Status: Backport
+Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
+---
+ include/qemu/osdep.h | 1 +
+ util/osdep.c | 66 ++++++++++++++++++++++++++++++++++++++++++++--------
+ 2 files changed, 57 insertions(+), 10 deletions(-)
+
+diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
+index 3b74f6fcb2..6855b94bbf 100644
+--- a/include/qemu/osdep.h
++++ b/include/qemu/osdep.h
+@@ -357,6 +357,7 @@ int qemu_dup(int fd);
+ int qemu_lock_fd(int fd, int64_t start, int64_t len, bool exclusive);
+ int qemu_unlock_fd(int fd, int64_t start, int64_t len);
+ int qemu_lock_fd_test(int fd, int64_t start, int64_t len, bool exclusive);
++bool qemu_has_ofd_lock(void);
+
+ #if defined(__HAIKU__) && defined(__i386__)
+ #define FMT_pid "%ld"
+diff --git a/util/osdep.c b/util/osdep.c
+index a2863c8e53..a479fedc4a 100644
+--- a/util/osdep.c
++++ b/util/osdep.c
+@@ -38,14 +38,6 @@ extern int madvise(caddr_t, size_t, int);
+ #include "qemu/error-report.h"
+ #include "monitor/monitor.h"
+
+-#ifdef F_OFD_SETLK
+-#define QEMU_SETLK F_OFD_SETLK
+-#define QEMU_GETLK F_OFD_GETLK
+-#else
+-#define QEMU_SETLK F_SETLK
+-#define QEMU_GETLK F_GETLK
+-#endif
+-
+ static bool fips_enabled = false;
+
+ static const char *hw_version = QEMU_HW_VERSION;
+@@ -82,6 +74,10 @@ int qemu_madvise(void *addr, size_t len, int advice)
+ }
+
+ #ifndef _WIN32
++
++static int fcntl_op_setlk = -1;
++static int fcntl_op_getlk = -1;
++
+ /*
+ * Dups an fd and sets the flags
+ */
+@@ -149,6 +145,54 @@ static int qemu_parse_fdset(const char *param)
+ return qemu_parse_fd(param);
+ }
+
++static void qemu_probe_lock_ops(void)
++{
++ if (fcntl_op_setlk == -1) {
++#ifdef F_OFD_SETLK
++ int fd;
++ int ret;
++ struct flock fl = {
++ .l_whence = SEEK_SET,
++ .l_start = 0,
++ .l_len = 0,
++ .l_type = F_WRLCK,
++ };
++
++ fd = open("/dev/null", O_RDWR);
++ if (fd < 0) {
++ fprintf(stderr,
++ "Failed to open /dev/null for OFD lock probing: %s\n",
++ strerror(errno));
++ fcntl_op_setlk = F_SETLK;
++ fcntl_op_getlk = F_GETLK;
++ return;
++ }
++ ret = fcntl(fd, F_OFD_GETLK, &fl);
++ close(fd);
++ if (!ret) {
++ fcntl_op_setlk = F_OFD_SETLK;
++ fcntl_op_getlk = F_OFD_GETLK;
++ } else {
++ fcntl_op_setlk = F_SETLK;
++ fcntl_op_getlk = F_GETLK;
++ }
++#else
++ fcntl_op_setlk = F_SETLK;
++ fcntl_op_getlk = F_GETLK;
++#endif
++ }
++}
++
++bool qemu_has_ofd_lock(void)
++{
++ qemu_probe_lock_ops();
++#ifdef F_OFD_SETLK
++ return fcntl_op_setlk == F_OFD_SETLK;
++#else
++ return false;
++#endif
++}
++
+ static int qemu_lock_fcntl(int fd, int64_t start, int64_t len, int fl_type)
+ {
+ int ret;
+@@ -158,7 +202,8 @@ static int qemu_lock_fcntl(int fd, int64_t start, int64_t len, int fl_type)
+ .l_len = len,
+ .l_type = fl_type,
+ };
+- ret = fcntl(fd, QEMU_SETLK, &fl);
++ qemu_probe_lock_ops();
++ ret = fcntl(fd, fcntl_op_setlk, &fl);
+ return ret == -1 ? -errno : 0;
+ }
+
+@@ -181,7 +226,8 @@ int qemu_lock_fd_test(int fd, int64_t start, int64_t len, bool exclusive)
+ .l_len = len,
+ .l_type = exclusive ? F_WRLCK : F_RDLCK,
+ };
+- ret = fcntl(fd, QEMU_GETLK, &fl);
++ qemu_probe_lock_ops();
++ ret = fcntl(fd, fcntl_op_getlk, &fl);
+ if (ret == -1) {
+ return -errno;
+ } else {
+--
+2.11.0
+
diff --git a/meta/recipes-devtools/qemu/qemu/0002-file-posix-Do-runtime-check-for-ofd-lock-API.patch b/meta/recipes-devtools/qemu/qemu/0002-file-posix-Do-runtime-check-for-ofd-lock-API.patch
new file mode 100644
index 0000000..0dacde4
--- /dev/null
+++ b/meta/recipes-devtools/qemu/qemu/0002-file-posix-Do-runtime-check-for-ofd-lock-API.patch
@@ -0,0 +1,71 @@
+From 2b218f5dbcca5fe728b1852d161d7a21fd02b2f5 Mon Sep 17 00:00:00 2001
+From: Fam Zheng <famz@redhat.com>
+Date: Fri, 11 Aug 2017 19:44:47 +0800
+Subject: [PATCH 2/2] file-posix: Do runtime check for ofd lock API
+
+It is reported that on Windows Subsystem for Linux, ofd operations fail
+with -EINVAL. In other words, QEMU binary built with system headers that
+exports F_OFD_SETLK doesn't necessarily run in an environment that
+actually supports it:
+
+$ qemu-system-aarch64 ... -drive file=test.vhdx,if=none,id=hd0 \
+ -device virtio-blk-pci,drive=hd0
+qemu-system-aarch64: -drive file=test.vhdx,if=none,id=hd0: Failed to unlock byte 100
+qemu-system-aarch64: -drive file=test.vhdx,if=none,id=hd0: Failed to unlock byte 100
+qemu-system-aarch64: -drive file=test.vhdx,if=none,id=hd0: Failed to lock byte 100
+
+As a matter of fact this is not WSL specific. It can happen when running
+a QEMU compiled against a newer glibc on an older kernel, such as in
+a containerized environment.
+
+Let's do a runtime check to cope with that.
+
+Reported-by: Andrew Baumann <Andrew.Baumann@microsoft.com>
+Reviewed-by: Eric Blake <eblake@redhat.com>
+Signed-off-by: Fam Zheng <famz@redhat.com>
+Signed-off-by: Kevin Wolf <kwolf@redhat.com>
+
+Upstream-Status: Backport
+Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
+---
+ block/file-posix.c | 19 ++++++++-----------
+ 1 file changed, 8 insertions(+), 11 deletions(-)
+
+diff --git a/block/file-posix.c b/block/file-posix.c
+index f4de022ae0..cb3bfce147 100644
+--- a/block/file-posix.c
++++ b/block/file-posix.c
+@@ -457,22 +457,19 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
+ switch (locking) {
+ case ON_OFF_AUTO_ON:
+ s->use_lock = true;
+-#ifndef F_OFD_SETLK
+- fprintf(stderr,
+- "File lock requested but OFD locking syscall is unavailable, "
+- "falling back to POSIX file locks.\n"
+- "Due to the implementation, locks can be lost unexpectedly.\n");
+-#endif
++ if (!qemu_has_ofd_lock()) {
++ fprintf(stderr,
++ "File lock requested but OFD locking syscall is "
++ "unavailable, falling back to POSIX file locks.\n"
++ "Due to the implementation, locks can be lost "
++ "unexpectedly.\n");
++ }
+ break;
+ case ON_OFF_AUTO_OFF:
+ s->use_lock = false;
+ break;
+ case ON_OFF_AUTO_AUTO:
+-#ifdef F_OFD_SETLK
+- s->use_lock = true;
+-#else
+- s->use_lock = false;
+-#endif
++ s->use_lock = qemu_has_ofd_lock();
+ break;
+ default:
+ abort();
+--
+2.11.0
+
diff --git a/meta/recipes-devtools/qemu/qemu_2.10.0-rc2.bb b/meta/recipes-devtools/qemu/qemu_2.10.0-rc2.bb
index 04d656b..08eaf19 100644
--- a/meta/recipes-devtools/qemu/qemu_2.10.0-rc2.bb
+++ b/meta/recipes-devtools/qemu/qemu_2.10.0-rc2.bb
@@ -24,6 +24,8 @@ SRC_URI = "http://wiki.qemu-project.org/download/${BP}.tar.bz2 \
file://0003-Introduce-condition-in-TPM-backend-for-notification.patch \
file://0004-Add-support-for-VM-suspend-resume-for-TPM-TIS-v2.9.patch \
file://apic-fixup-fallthrough-to-PIC.patch \
+ file://0001-osdep-Add-runtime-OFD-lock-detection.patch \
+ file://0002-file-posix-Do-runtime-check-for-ofd-lock-API.patch \
"
SRC_URI_append_class-native = " \
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] qemu conf: replace deprecated option with new option
2017-08-18 10:19 [PATCH 0/2] Fix runqemu startup failure Chen Qi
2017-08-18 10:19 ` [PATCH 1/2] qemu: backport patches to fix boot failure Chen Qi
@ 2017-08-18 10:19 ` Chen Qi
1 sibling, 0 replies; 3+ messages in thread
From: Chen Qi @ 2017-08-18 10:19 UTC (permalink / raw)
To: openembedded-core
Replace the deprecated '-usbdevice' option with '-device usb-xx' option.
This would fix runqemu boot error like below.
'-usbdevice' is deprecated, please use '-device usb-...' instead
Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
meta/conf/machine/include/qemuboot-mips.inc | 2 +-
meta/conf/machine/include/qemuboot-x86.inc | 2 +-
meta/conf/machine/qemuarm.conf | 2 +-
meta/conf/machine/qemuppc.conf | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/meta/conf/machine/include/qemuboot-mips.inc b/meta/conf/machine/include/qemuboot-mips.inc
index 0c60cf2..7d9fa52 100644
--- a/meta/conf/machine/include/qemuboot-mips.inc
+++ b/meta/conf/machine/include/qemuboot-mips.inc
@@ -4,5 +4,5 @@ QB_MEM = "-m 256"
QB_MACHINE = "-machine malta"
QB_KERNEL_CMDLINE_APPEND = "console=ttyS0 console=tty"
# Add the 'virtio-rng-pci' device otherwise the guest may run out of entropy
-QB_OPT_APPEND = "-vga cirrus -show-cursor -usb -usbdevice tablet -device virtio-rng-pci"
+QB_OPT_APPEND = "-vga cirrus -show-cursor -usb -device usb-tablet -device virtio-rng-pci"
QB_SYSTEM_NAME = "qemu-system-${TUNE_ARCH}"
diff --git a/meta/conf/machine/include/qemuboot-x86.inc b/meta/conf/machine/include/qemuboot-x86.inc
index acf9d55..0596e2e 100644
--- a/meta/conf/machine/include/qemuboot-x86.inc
+++ b/meta/conf/machine/include/qemuboot-x86.inc
@@ -12,7 +12,7 @@ QB_AUDIO_DRV = "alsa"
QB_AUDIO_OPT = "-soundhw ac97,es1370"
QB_KERNEL_CMDLINE_APPEND = "vga=0 uvesafb.mode_option=${UVESA_MODE} oprofile.timer=1 uvesafb.task_timeout=-1"
# Add the 'virtio-rng-pci' device otherwise the guest may run out of entropy
-QB_OPT_APPEND = "-vga vmware -show-cursor -usb -usbdevice tablet -device virtio-rng-pci"
+QB_OPT_APPEND = "-vga vmware -show-cursor -usb -device usb-tablet -device virtio-rng-pci"
KERNEL_MODULE_AUTOLOAD += "uvesafb"
KERNEL_MODULE_PROBECONF += "uvesafb"
diff --git a/meta/conf/machine/qemuarm.conf b/meta/conf/machine/qemuarm.conf
index 6b875e4..1f0a65f 100644
--- a/meta/conf/machine/qemuarm.conf
+++ b/meta/conf/machine/qemuarm.conf
@@ -15,6 +15,6 @@ QB_SYSTEM_NAME = "qemu-system-arm"
QB_MACHINE = "-machine versatilepb"
QB_KERNEL_CMDLINE_APPEND = "console=ttyAMA0,115200 console=tty"
# Add the 'virtio-rng-pci' device otherwise the guest may run out of entropy
-QB_OPT_APPEND = "-show-cursor -usb -usbdevice tablet -device virtio-rng-pci"
+QB_OPT_APPEND = "-show-cursor -usb -device usb-tablet -device virtio-rng-pci"
PREFERRED_VERSION_linux-yocto ??= "4.10%"
QB_DTB = "${@base_version_less_or_equal('PREFERRED_VERSION_linux-yocto', '4.7', '', 'zImage-versatile-pb.dtb', d)}"
diff --git a/meta/conf/machine/qemuppc.conf b/meta/conf/machine/qemuppc.conf
index a9ef64b..537b2f6 100644
--- a/meta/conf/machine/qemuppc.conf
+++ b/meta/conf/machine/qemuppc.conf
@@ -17,5 +17,5 @@ QB_MACHINE = "-machine mac99"
QB_CPU = "-cpu G4"
QB_KERNEL_CMDLINE_APPEND = "console=tty console=ttyS0"
# Add the 'virtio-rng-pci' device otherwise the guest may run out of entropy
-QB_OPT_APPEND = "-show-cursor -usb -usbdevice tablet -device virtio-rng-pci"
+QB_OPT_APPEND = "-show-cursor -usb -device usb-tablet -device virtio-rng-pci"
QB_TAP_OPT = "-netdev tap,id=net0,ifname=@TAP@,script=no,downscript=no"
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-08-18 10:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-18 10:19 [PATCH 0/2] Fix runqemu startup failure Chen Qi
2017-08-18 10:19 ` [PATCH 1/2] qemu: backport patches to fix boot failure Chen Qi
2017-08-18 10:19 ` [PATCH 2/2] qemu conf: replace deprecated option with new option Chen Qi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox