qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] block: Set the name of BlockBackend if possible
@ 2022-10-27 20:23 Annie Li
  2022-10-27 20:24 ` [PATCH 2/2] iotests: Adjust 186.out to account for 'null' node-name Annie Li
  0 siblings, 1 reply; 2+ messages in thread
From: Annie Li @ 2022-10-27 20:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: annie.li, mark.kanda

When QEMU emulates the SCSI device, it sets the 'device_id' of
the SCSI device with the serial number configured by 'serial='
property, or with 'blk->name' of the block backend otherwise.
Then QEMU emulates SCSI commands and fills the mandatory Device
identification page(0x83) with the 'device_id' info.

However, 'blk->name' of the block backend is NULL if the block
backend is defined by '-blockdev' option. This causes the QEMU
returns unconfigured empty page to the guest. As a result, this
may cause various issues on the guest side. For example, Windows
guest crashes due this in BZ#1708490, BZ#1722710#c10. This crash
issue has been fixed in Windows vioscsi driver by patching the vpd
page[1], but it is better for QEMU to return the non NULL vpd page
if possible.

This patch sets the 'blk->name' of the block backend that is
defined by '-blockdev' option, so the QEMU returns non NULL vpd
page when emulating SCSI device.

[1] https://github.com/virtio-win/kvm-guest-drivers-windows/commit/b57548c769ed9f431c34f6449ce432dd077cb02e

Signed-off-by: Annie Li <annie.li@oracle.com>
---
 block/block-backend.c                       | 10 +++++++++-
 hw/core/qdev-properties-system.c            |  1 +
 include/sysemu/block-backend-global-state.h |  2 ++
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/block/block-backend.c b/block/block-backend.c
index aa4adf06ae..255b009270 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -471,8 +471,9 @@ BlockBackend *blk_new_open(const char *filename, const char *reference,
 static void blk_delete(BlockBackend *blk)
 {
     assert(!blk->refcnt);
-    assert(!blk->name);
     assert(!blk->dev);
+    g_free(blk->name);
+    blk->name = NULL;
     if (blk->public.throttle_group_member.throttle_state) {
         blk_io_limits_disable(blk);
     }
@@ -2594,3 +2595,10 @@ int blk_make_empty(BlockBackend *blk, Error **errp)
 
     return bdrv_make_empty(blk->root, errp);
 }
+
+void blk_set_name(BlockBackend *blk, char *name)
+{
+    if (!blk->name) {
+        blk->name = g_strdup(name);
+    }
+}
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index a91f60567a..9504acf4df 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -144,6 +144,7 @@ static void set_drive_helper(Object *obj, Visitor *v, const char *name,
             ctx = iothread ? bdrv_get_aio_context(bs) : qemu_get_aio_context();
             blk = blk_new(ctx, 0, BLK_PERM_ALL);
             blk_created = true;
+            blk_set_name(blk, str);
 
             ret = blk_insert_bs(blk, bs, errp);
             if (ret < 0) {
diff --git a/include/sysemu/block-backend-global-state.h b/include/sysemu/block-backend-global-state.h
index 415f0c91d7..95f166f9c7 100644
--- a/include/sysemu/block-backend-global-state.h
+++ b/include/sysemu/block-backend-global-state.h
@@ -113,4 +113,6 @@ const BdrvChild *blk_root(BlockBackend *blk);
 
 int blk_make_empty(BlockBackend *blk, Error **errp);
 
+void blk_set_name(BlockBackend *blk, char *name);
+
 #endif /* BLOCK_BACKEND_GLOBAL_STATE_H */
-- 
2.34.3



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] iotests: Adjust 186.out to account for 'null' node-name
  2022-10-27 20:23 [PATCH 1/2] block: Set the name of BlockBackend if possible Annie Li
@ 2022-10-27 20:24 ` Annie Li
  0 siblings, 0 replies; 2+ messages in thread
From: Annie Li @ 2022-10-27 20:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: annie.li, mark.kanda

A recent enhancement for setting the block backend name fails test 186 due to a
'null' node-name. This is expected; adjust the expected test output accordingly.

Signed-off-by: Mark Kanda <mark.kanda@oracle.com>
Signed-off-by: Annie Li <annie.li@oracle.com>
---
 tests/qemu-iotests/186.out | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/tests/qemu-iotests/186.out b/tests/qemu-iotests/186.out
index 01530040e5..27316bba46 100644
--- a/tests/qemu-iotests/186.out
+++ b/tests/qemu-iotests/186.out
@@ -57,7 +57,7 @@ qdev_id: [not inserted]
 Testing: -blockdev driver=null-co,read-zeroes=on,node-name=null -device ide-hd,drive=null
 QEMU X.Y.Z monitor - type 'help' for more information
 (qemu) info block
-null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
+null (null): json:{"read-zeroes": true, "driver": "null-co"} (null-co)
     Attached to:      /machine/peripheral-anon/device[N]
     Cache mode:       writeback
 (qemu) quit
@@ -65,7 +65,7 @@ null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
 Testing: -blockdev driver=null-co,read-zeroes=on,node-name=null -device ide-hd,drive=null,id=qdev_id
 QEMU X.Y.Z monitor - type 'help' for more information
 (qemu) info block
-null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
+null (null): json:{"read-zeroes": true, "driver": "null-co"} (null-co)
     Attached to:      qdev_id
     Cache mode:       writeback
 (qemu) quit
@@ -73,7 +73,7 @@ null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
 Testing: -blockdev driver=null-co,read-zeroes=on,node-name=null -device scsi-hd,drive=null
 QEMU X.Y.Z monitor - type 'help' for more information
 (qemu) info block
-null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
+null (null): json:{"read-zeroes": true, "driver": "null-co"} (null-co)
     Attached to:      /machine/peripheral-anon/device[N]
     Cache mode:       writeback
 (qemu) quit
@@ -81,7 +81,7 @@ null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
 Testing: -blockdev driver=null-co,read-zeroes=on,node-name=null -device scsi-hd,drive=null,id=qdev_id
 QEMU X.Y.Z monitor - type 'help' for more information
 (qemu) info block
-null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
+null (null): json:{"read-zeroes": true, "driver": "null-co"} (null-co)
     Attached to:      qdev_id
     Cache mode:       writeback
 (qemu) quit
@@ -89,7 +89,7 @@ null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
 Testing: -blockdev driver=null-co,read-zeroes=on,node-name=null -device virtio-blk-pci,drive=null
 QEMU X.Y.Z monitor - type 'help' for more information
 (qemu) info block
-null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
+null (null): json:{"read-zeroes": true, "driver": "null-co"} (null-co)
     Attached to:      /machine/peripheral-anon/device[N]/virtio-backend
     Cache mode:       writeback
 (qemu) quit
@@ -97,7 +97,7 @@ null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
 Testing: -blockdev driver=null-co,read-zeroes=on,node-name=null -device virtio-blk-pci,drive=null,id=qdev_id
 QEMU X.Y.Z monitor - type 'help' for more information
 (qemu) info block
-null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
+null (null): json:{"read-zeroes": true, "driver": "null-co"} (null-co)
     Attached to:      /machine/peripheral/qdev_id/virtio-backend
     Cache mode:       writeback
 (qemu) quit
@@ -105,7 +105,7 @@ null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
 Testing: -blockdev driver=null-co,read-zeroes=on,node-name=null -device floppy,drive=null
 QEMU X.Y.Z monitor - type 'help' for more information
 (qemu) info block
-null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
+null (null): json:{"read-zeroes": true, "driver": "null-co"} (null-co)
     Attached to:      /machine/peripheral-anon/device[N]
     Removable device: not locked, tray closed
     Cache mode:       writeback
@@ -114,7 +114,7 @@ null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
 Testing: -blockdev driver=null-co,read-zeroes=on,node-name=null -device floppy,drive=null,id=qdev_id
 QEMU X.Y.Z monitor - type 'help' for more information
 (qemu) info block
-null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
+null (null): json:{"read-zeroes": true, "driver": "null-co"} (null-co)
     Attached to:      qdev_id
     Removable device: not locked, tray closed
     Cache mode:       writeback
@@ -123,7 +123,7 @@ null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
 Testing: -blockdev driver=null-co,read-zeroes=on,node-name=null -device ide-cd,drive=null
 QEMU X.Y.Z monitor - type 'help' for more information
 (qemu) info block
-null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
+null (null): json:{"read-zeroes": true, "driver": "null-co"} (null-co)
     Attached to:      /machine/peripheral-anon/device[N]
     Removable device: not locked, tray closed
     Cache mode:       writeback
@@ -132,7 +132,7 @@ null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
 Testing: -blockdev driver=null-co,read-zeroes=on,node-name=null -device ide-cd,drive=null,id=qdev_id
 QEMU X.Y.Z monitor - type 'help' for more information
 (qemu) info block
-null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
+null (null): json:{"read-zeroes": true, "driver": "null-co"} (null-co)
     Attached to:      qdev_id
     Removable device: not locked, tray closed
     Cache mode:       writeback
@@ -141,7 +141,7 @@ null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
 Testing: -blockdev driver=null-co,read-zeroes=on,node-name=null -device scsi-cd,drive=null
 QEMU X.Y.Z monitor - type 'help' for more information
 (qemu) info block
-null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
+null (null): json:{"read-zeroes": true, "driver": "null-co"} (null-co)
     Attached to:      /machine/peripheral-anon/device[N]
     Removable device: not locked, tray closed
     Cache mode:       writeback
@@ -150,7 +150,7 @@ null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
 Testing: -blockdev driver=null-co,read-zeroes=on,node-name=null -device scsi-cd,drive=null,id=qdev_id
 QEMU X.Y.Z monitor - type 'help' for more information
 (qemu) info block
-null: json:{"read-zeroes": true, "driver": "null-co"} (null-co)
+null (null): json:{"read-zeroes": true, "driver": "null-co"} (null-co)
     Attached to:      qdev_id
     Removable device: not locked, tray closed
     Cache mode:       writeback
@@ -166,7 +166,7 @@ none0 (null): json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
     Removable device: not locked, tray closed
     Cache mode:       writeback
 
-null: json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
+null (null): json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
     Attached to:      qdev_id
     Cache mode:       writeback
 (qemu) quit
@@ -178,7 +178,7 @@ none0 (null): json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
     Removable device: not locked, tray closed
     Cache mode:       writeback
 
-null: json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
+null (null): json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
     Attached to:      qdev_id
     Cache mode:       writeback
 (qemu) quit
@@ -190,7 +190,7 @@ none0 (null): json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
     Removable device: not locked, tray closed
     Cache mode:       writeback
 
-null: json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
+null (null): json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
     Attached to:      /machine/peripheral/qdev_id/virtio-backend
     Cache mode:       writeback
 (qemu) quit
@@ -202,7 +202,7 @@ none0 (null): json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
     Removable device: not locked, tray closed
     Cache mode:       writeback
 
-null: json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
+null (null): json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
     Attached to:      qdev_id
     Removable device: not locked, tray closed
     Cache mode:       writeback
@@ -215,7 +215,7 @@ none0 (null): json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
     Removable device: not locked, tray closed
     Cache mode:       writeback
 
-null: json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
+null (null): json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
     Attached to:      qdev_id
     Removable device: not locked, tray closed
     Cache mode:       writeback
@@ -228,7 +228,7 @@ none0 (null): json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
     Removable device: not locked, tray closed
     Cache mode:       writeback
 
-null: json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
+null (null): json:{"read-zeroes": "on", "driver": "null-co"} (null-co)
     Attached to:      qdev_id
     Removable device: not locked, tray closed
     Cache mode:       writeback
-- 
2.34.3



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-10-27 20:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-27 20:23 [PATCH 1/2] block: Set the name of BlockBackend if possible Annie Li
2022-10-27 20:24 ` [PATCH 2/2] iotests: Adjust 186.out to account for 'null' node-name Annie Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).