From eee1dfa354097a4ff1f92e57fefa64701fe723a2 Mon Sep 17 00:00:00 2001 From: ChulHo Song Date: Wed, 30 Sep 2015 13:28:56 +0900 Subject: [PATCH] sdcard: allocate "DriveInfo" to delete the "BlockBackend" automatically When the sdcard is detached, "virtio_blk_device_unrealize" marks auto deletion flag to the "DriveInfo". But "qmp_marshal_input_blockdev_add" does not create the "DriveInfo". To destroy BlockBackend object automatically we need to create dummy "DriveInfo". Change-Id: I8501c5b14daab487e72b4b6b6a0744475c6553a3 Signed-off-by: ChulHo Song --- tizen/src/util/device_hotplug.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tizen/src/util/device_hotplug.c b/tizen/src/util/device_hotplug.c index f6d8994d6c..d32235d7ff 100644 --- a/tizen/src/util/device_hotplug.c +++ b/tizen/src/util/device_hotplug.c @@ -30,6 +30,7 @@ #include "qemu/config-file.h" #include "hw/qdev.h" #include "qemu/event_notifier.h" +#include "sysemu/block-backend.h" #include "emulator.h" #include "emul_state.h" @@ -105,6 +106,7 @@ static bool do_sdcard_attach(const char * const file) gchar *sdcard_img = g_path_get_basename(file); gchar *sdcard_device_id = g_strdup_printf("device_id_%s", sdcard_img); gchar *sdcard_drive_id = g_strdup_printf("drive_id_%s", sdcard_img); + DriveInfo* dinfo = NULL; g_free(sdcard_img); @@ -117,6 +119,10 @@ static bool do_sdcard_attach(const char * const file) qmp_marshal_input_blockdev_add(default_mon, qdict, NULL); + dinfo = g_malloc0(sizeof(*dinfo)); + dinfo->type = IF_VIRTIO; + blk_set_legacy_dinfo(blk_by_name(sdcard_device_id), dinfo); + QDECREF(qdict); qdict = qdict_new(); -- 2.34.1