From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, stefano.stabellini@eu.citrix.com
Subject: [Qemu-devel] [PATCH v2 2/2] xen: Don't peek behind the BlockDriverState abstraction
Date: Wed, 6 Jun 2012 19:35:19 +0200 [thread overview]
Message-ID: <1339004119-3245-3-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1339004119-3245-1-git-send-email-armbru@redhat.com>
First offender is xen_config_dev_blk()'s use of disk->bdrv->filename.
Get the filename from disk->opts instead. Same result, except for
snapshots: there, we now get the filename specified by the user
instead of the name of the temporary image created by bdrv_open().
Should be an improvement.
Second offender is blk_init()'s use of blkdev->bs->drv->format_name.
Simply use the appropriate interface to get the format name.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
hw/xen_devconfig.c | 6 +++---
hw/xen_disk.c | 6 ++++--
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/hw/xen_devconfig.c b/hw/xen_devconfig.c
index 7b7b0a2..0928613 100644
--- a/hw/xen_devconfig.c
+++ b/hw/xen_devconfig.c
@@ -1,6 +1,5 @@
#include "xen_backend.h"
#include "blockdev.h"
-#include "block_int.h" /* XXX */
/* ------------------------------------------------------------- */
@@ -99,10 +98,11 @@ int xen_config_dev_blk(DriveInfo *disk)
int cdrom = disk->media_cd;
const char *devtype = cdrom ? "cdrom" : "disk";
const char *mode = cdrom ? "r" : "w";
+ const char *filename = qemu_opt_get(disk->opts, "file");
snprintf(device_name, sizeof(device_name), "xvd%c", 'a' + disk->unit);
xen_be_printf(NULL, 1, "config disk %d [%s]: %s\n",
- disk->unit, device_name, disk->bdrv->filename);
+ disk->unit, device_name, filename);
xen_config_dev_dirs("vbd", "qdisk", vdev, fe, be, sizeof(fe));
/* frontend */
@@ -112,7 +112,7 @@ int xen_config_dev_blk(DriveInfo *disk)
/* backend */
xenstore_write_str(be, "dev", device_name);
xenstore_write_str(be, "type", "file");
- xenstore_write_str(be, "params", disk->bdrv->filename);
+ xenstore_write_str(be, "params", filename);
xenstore_write_str(be, "mode", mode);
/* common stuff */
diff --git a/hw/xen_disk.c b/hw/xen_disk.c
index 07594bc..52131cb 100644
--- a/hw/xen_disk.c
+++ b/hw/xen_disk.c
@@ -40,7 +40,6 @@
#include <xen/io/xenbus.h>
#include "hw.h"
-#include "block_int.h"
#include "qemu-char.h"
#include "xen_blkif.h"
#include "xen_backend.h"
@@ -634,9 +633,12 @@ static int blk_init(struct XenDevice *xendev)
blkdev->file_blk = BLOCK_SIZE;
blkdev->file_size = bdrv_getlength(blkdev->bs);
if (blkdev->file_size < 0) {
+ char fmt_name[128];
+
+ bdrv_get_format(blkdev->bs, fmt_name, sizeof(fmt_name));
xen_be_printf(&blkdev->xendev, 1, "bdrv_getlength: %d (%s) | drv %s\n",
(int)blkdev->file_size, strerror(-blkdev->file_size),
- blkdev->bs->drv ? blkdev->bs->drv->format_name : "-");
+ fmt_name[0] ? fmt_name : "-");
blkdev->file_size = 0;
}
--
1.7.6.5
next prev parent reply other threads:[~2012-06-06 17:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-06 17:35 [Qemu-devel] [PATCH v2 0/2] xen: Clean up BlockDriverState use Markus Armbruster
2012-06-06 17:35 ` [Qemu-devel] [PATCH v2 1/2] xen: Don't change -drive if=xen device name during machine init Markus Armbruster
2012-06-06 17:35 ` Markus Armbruster [this message]
2012-06-07 15:53 ` [Qemu-devel] [PATCH v2 0/2] xen: Clean up BlockDriverState use Stefano Stabellini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1339004119-3245-3-git-send-email-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefano.stabellini@eu.citrix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).