From: Kevin Wolf <kwolf@redhat.com>
To: anthony@codemonkey.ws
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 15/19] block: Decouple savevm from DriveInfo
Date: Tue, 15 Jun 2010 16:19:37 +0200 [thread overview]
Message-ID: <1276611581-3757-16-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1276611581-3757-1-git-send-email-kwolf@redhat.com>
From: Markus Armbruster <armbru@redhat.com>
We find snapshots by iterating over the list of drives defined with
drive_init(). This misses host block devices defined by other means.
Such means don't exist now, but will be introduced later in this
series.
Iterate over all host block devices instead, with bdrv_next().
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
savevm.c | 40 ++++++++++++++++++----------------------
1 files changed, 18 insertions(+), 22 deletions(-)
diff --git a/savevm.c b/savevm.c
index ab58d63..20354a8 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1578,12 +1578,13 @@ out:
static BlockDriverState *get_bs_snapshots(void)
{
BlockDriverState *bs;
- DriveInfo *dinfo;
if (bs_snapshots)
return bs_snapshots;
- QTAILQ_FOREACH(dinfo, &drives, next) {
- bs = dinfo->bdrv;
+ /* FIXME what if bs_snapshots gets hot-unplugged? */
+
+ bs = NULL;
+ while ((bs = bdrv_next(bs))) {
if (bdrv_can_snapshot(bs)) {
goto ok;
}
@@ -1622,12 +1623,11 @@ static int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info,
static int del_existing_snapshots(Monitor *mon, const char *name)
{
BlockDriverState *bs;
- DriveInfo *dinfo;
QEMUSnapshotInfo sn1, *snapshot = &sn1;
int ret;
- QTAILQ_FOREACH(dinfo, &drives, next) {
- bs = dinfo->bdrv;
+ bs = NULL;
+ while ((bs = bdrv_next(bs))) {
if (bdrv_can_snapshot(bs) &&
bdrv_snapshot_find(bs, snapshot, name) >= 0)
{
@@ -1646,7 +1646,6 @@ static int del_existing_snapshots(Monitor *mon, const char *name)
void do_savevm(Monitor *mon, const QDict *qdict)
{
- DriveInfo *dinfo;
BlockDriverState *bs, *bs1;
QEMUSnapshotInfo sn1, *sn = &sn1, old_sn1, *old_sn = &old_sn1;
int ret;
@@ -1661,8 +1660,8 @@ void do_savevm(Monitor *mon, const QDict *qdict)
const char *name = qdict_get_try_str(qdict, "name");
/* Verify if there is a device that doesn't support snapshots and is writable */
- QTAILQ_FOREACH(dinfo, &drives, next) {
- bs = dinfo->bdrv;
+ bs = NULL;
+ while ((bs = bdrv_next(bs))) {
if (bdrv_is_removable(bs) || bdrv_is_read_only(bs)) {
continue;
@@ -1730,8 +1729,8 @@ void do_savevm(Monitor *mon, const QDict *qdict)
/* create the snapshots */
- QTAILQ_FOREACH(dinfo, &drives, next) {
- bs1 = dinfo->bdrv;
+ bs1 = NULL;
+ while ((bs1 = bdrv_next(bs1))) {
if (bdrv_can_snapshot(bs1)) {
/* Write VM state size only to the image that contains the state */
sn->vm_state_size = (bs == bs1 ? vm_state_size : 0);
@@ -1750,15 +1749,14 @@ void do_savevm(Monitor *mon, const QDict *qdict)
int load_vmstate(const char *name)
{
- DriveInfo *dinfo;
BlockDriverState *bs, *bs1;
QEMUSnapshotInfo sn;
QEMUFile *f;
int ret;
/* Verify if there is a device that doesn't support snapshots and is writable */
- QTAILQ_FOREACH(dinfo, &drives, next) {
- bs = dinfo->bdrv;
+ bs = NULL;
+ while ((bs = bdrv_next(bs))) {
if (bdrv_is_removable(bs) || bdrv_is_read_only(bs)) {
continue;
@@ -1780,8 +1778,8 @@ int load_vmstate(const char *name)
/* Flush all IO requests so they don't interfere with the new state. */
qemu_aio_flush();
- QTAILQ_FOREACH(dinfo, &drives, next) {
- bs1 = dinfo->bdrv;
+ bs1 = NULL;
+ while ((bs1 = bdrv_next(bs1))) {
if (bdrv_can_snapshot(bs1)) {
ret = bdrv_snapshot_goto(bs1, name);
if (ret < 0) {
@@ -1831,7 +1829,6 @@ int load_vmstate(const char *name)
void do_delvm(Monitor *mon, const QDict *qdict)
{
- DriveInfo *dinfo;
BlockDriverState *bs, *bs1;
int ret;
const char *name = qdict_get_str(qdict, "name");
@@ -1842,8 +1839,8 @@ void do_delvm(Monitor *mon, const QDict *qdict)
return;
}
- QTAILQ_FOREACH(dinfo, &drives, next) {
- bs1 = dinfo->bdrv;
+ bs1 = NULL;
+ while ((bs1 = bdrv_next(bs1))) {
if (bdrv_can_snapshot(bs1)) {
ret = bdrv_snapshot_delete(bs1, name);
if (ret < 0) {
@@ -1861,7 +1858,6 @@ void do_delvm(Monitor *mon, const QDict *qdict)
void do_info_snapshots(Monitor *mon)
{
- DriveInfo *dinfo;
BlockDriverState *bs, *bs1;
QEMUSnapshotInfo *sn_tab, *sn;
int nb_sns, i;
@@ -1873,8 +1869,8 @@ void do_info_snapshots(Monitor *mon)
return;
}
monitor_printf(mon, "Snapshot devices:");
- QTAILQ_FOREACH(dinfo, &drives, next) {
- bs1 = dinfo->bdrv;
+ bs1 = NULL;
+ while ((bs1 = bdrv_next(bs1))) {
if (bdrv_can_snapshot(bs1)) {
if (bs == bs1)
monitor_printf(mon, " %s", bdrv_get_device_name(bs1));
--
1.6.6.1
next prev parent reply other threads:[~2010-06-15 14:20 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-15 14:19 [Qemu-devel] [PULL 00/19] Block patches Kevin Wolf
2010-06-15 14:19 ` [Qemu-devel] [PATCH 01/19] vpc: Read/write multiple sectors at once Kevin Wolf
2010-06-15 14:19 ` [Qemu-devel] [PATCH 02/19] qcow2: Allow get_refcount to return errors Kevin Wolf
2010-06-15 14:19 ` [Qemu-devel] [PATCH 03/19] qcow2: Allow alloc_clusters_noref " Kevin Wolf
2010-06-15 14:19 ` [Qemu-devel] [PATCH 04/19] qcow2: Return real error code in load_refcount_block Kevin Wolf
2010-06-15 14:19 ` [Qemu-devel] [PATCH 05/19] savevm: Really verify if a drive supports snapshots Kevin Wolf
2010-06-15 14:19 ` [Qemu-devel] [PATCH 06/19] Fix regression for "-drive file=" Kevin Wolf
2010-06-15 14:19 ` [Qemu-devel] [PATCH 07/19] qcow2: Restore L1 entry on l2_allocate failure Kevin Wolf
2010-06-15 14:19 ` [Qemu-devel] [PATCH 08/19] cow: use pread/pwrite Kevin Wolf
2010-06-15 14:19 ` [Qemu-devel] [PATCH 09/19] cow: stop using mmap Kevin Wolf
2010-06-15 14:19 ` [Qemu-devel] [PATCH 10/19] cow: use qemu block API Kevin Wolf
2010-06-15 14:19 ` [Qemu-devel] [PATCH 11/19] block: Move error actions from DriveInfo to BlockDriverState Kevin Wolf
2010-06-15 14:19 ` [Qemu-devel] [PATCH 12/19] block: Decouple block device "commit all" from DriveInfo Kevin Wolf
2010-06-15 14:19 ` [Qemu-devel] [PATCH 13/19] monitor: Make "commit FOO" complain when FOO doesn't exist Kevin Wolf
2010-06-15 14:19 ` [Qemu-devel] [PATCH 14/19] block: New bdrv_next() Kevin Wolf
2010-06-15 14:19 ` Kevin Wolf [this message]
2010-06-15 14:19 ` [Qemu-devel] [PATCH 16/19] blockdev: Give drives internal linkage Kevin Wolf
2010-06-15 14:19 ` [Qemu-devel] [PATCH 17/19] Correct definitions for FD_CMD_SAVE and FD_CMD_RESTORE Kevin Wolf
2010-06-15 14:28 ` [Qemu-devel] " Anthony Liguori
2010-06-15 14:42 ` Kevin Wolf
2010-06-15 14:47 ` Jes Sorensen
2010-06-15 14:52 ` Kevin Wolf
2010-06-15 14:54 ` Jes Sorensen
2010-06-15 14:19 ` [Qemu-devel] [PATCH 18/19] block: fix a warning and possible truncation Kevin Wolf
2010-06-15 14:19 ` [Qemu-devel] [PATCH 19/19] xen: Fix build error due to missing include Kevin Wolf
2010-06-15 14:26 ` [Qemu-devel] [PULL 00/19] Block patches Anthony Liguori
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=1276611581-3757-16-git-send-email-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=anthony@codemonkey.ws \
--cc=qemu-devel@nongnu.org \
/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).