yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-block-pass-BlockDriver-reference-to-the-.bdrv_co_cre.patch

ddf19c
From 25c528b30f8774f33e957d14060805398da524d9 Mon Sep 17 00:00:00 2001
ddf19c
From: Maxim Levitsky <mlevitsk@redhat.com>
ddf19c
Date: Thu, 26 Mar 2020 20:23:06 +0000
ddf19c
Subject: [PATCH 1/4] block: pass BlockDriver reference to the .bdrv_co_create
ddf19c
ddf19c
RH-Author: Maxim Levitsky <mlevitsk@redhat.com>
ddf19c
Message-id: <20200326202307.9264-2-mlevitsk@redhat.com>
ddf19c
Patchwork-id: 94447
ddf19c
O-Subject: [RHEL-AV-8.2.0 qemu-kvm PATCH 1/2] block: pass BlockDriver reference to the .bdrv_co_create
ddf19c
Bugzilla: 1816007
ddf19c
RH-Acked-by: Danilo de Paula <ddepaula@redhat.com>
ddf19c
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
ddf19c
RH-Acked-by: Max Reitz <mreitz@redhat.com>
ddf19c
ddf19c
This will allow the reuse of a single generic .bdrv_co_create
ddf19c
implementation for several drivers.
ddf19c
No functional changes.
ddf19c
ddf19c
Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
ddf19c
Message-Id: <20200326011218.29230-2-mlevitsk@redhat.com>
ddf19c
Reviewed-by: Denis V. Lunev <den@openvz.org>
ddf19c
Signed-off-by: Max Reitz <mreitz@redhat.com>
ddf19c
(cherry picked from commit b92902dfeaafbceaf744ab7473f2d070284f6172)
ddf19c
Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
ddf19c
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ddf19c
---
ddf19c
 block.c                   | 3 ++-
ddf19c
 block/crypto.c            | 3 ++-
ddf19c
 block/file-posix.c        | 4 +++-
ddf19c
 block/file-win32.c        | 4 +++-
ddf19c
 block/gluster.c           | 3 ++-
ddf19c
 block/nfs.c               | 4 +++-
ddf19c
 block/parallels.c         | 3 ++-
ddf19c
 block/qcow.c              | 3 ++-
ddf19c
 block/qcow2.c             | 4 +++-
ddf19c
 block/qed.c               | 3 ++-
ddf19c
 block/raw-format.c        | 4 +++-
ddf19c
 block/rbd.c               | 3 ++-
ddf19c
 block/sheepdog.c          | 4 +++-
ddf19c
 block/ssh.c               | 4 +++-
ddf19c
 block/vdi.c               | 4 +++-
ddf19c
 block/vhdx.c              | 3 ++-
ddf19c
 block/vmdk.c              | 4 +++-
ddf19c
 block/vpc.c               | 6 ++++--
ddf19c
 include/block/block_int.h | 3 ++-
ddf19c
 19 files changed, 49 insertions(+), 20 deletions(-)
ddf19c
ddf19c
diff --git a/block.c b/block.c
ddf19c
index ec29b1e..f9a1c5b 100644
ddf19c
--- a/block.c
ddf19c
+++ b/block.c
ddf19c
@@ -482,7 +482,8 @@ static void coroutine_fn bdrv_create_co_entry(void *opaque)
ddf19c
     CreateCo *cco = opaque;
ddf19c
     assert(cco->drv);
ddf19c
 
ddf19c
-    ret = cco->drv->bdrv_co_create_opts(cco->filename, cco->opts, &local_err);
ddf19c
+    ret = cco->drv->bdrv_co_create_opts(cco->drv,
ddf19c
+                                        cco->filename, cco->opts, &local_err);
ddf19c
     error_propagate(&cco->err, local_err);
ddf19c
     cco->ret = ret;
ddf19c
 }
ddf19c
diff --git a/block/crypto.c b/block/crypto.c
ddf19c
index 2482383..970d463 100644
ddf19c
--- a/block/crypto.c
ddf19c
+++ b/block/crypto.c
ddf19c
@@ -539,7 +539,8 @@ fail:
ddf19c
     return ret;
ddf19c
 }
ddf19c
 
ddf19c
-static int coroutine_fn block_crypto_co_create_opts_luks(const char *filename,
ddf19c
+static int coroutine_fn block_crypto_co_create_opts_luks(BlockDriver *drv,
ddf19c
+                                                         const char *filename,
ddf19c
                                                          QemuOpts *opts,
ddf19c
                                                          Error **errp)
ddf19c
 {
ddf19c
diff --git a/block/file-posix.c b/block/file-posix.c
ddf19c
index fd29372..a2e0a74 100644
ddf19c
--- a/block/file-posix.c
ddf19c
+++ b/block/file-posix.c
ddf19c
@@ -2346,7 +2346,9 @@ out:
ddf19c
     return result;
ddf19c
 }
ddf19c
 
ddf19c
-static int coroutine_fn raw_co_create_opts(const char *filename, QemuOpts *opts,
ddf19c
+static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
ddf19c
+                                           const char *filename,
ddf19c
+                                           QemuOpts *opts,
ddf19c
                                            Error **errp)
ddf19c
 {
ddf19c
     BlockdevCreateOptions options;
ddf19c
diff --git a/block/file-win32.c b/block/file-win32.c
ddf19c
index 77e8ff7..1585983 100644
ddf19c
--- a/block/file-win32.c
ddf19c
+++ b/block/file-win32.c
ddf19c
@@ -588,7 +588,9 @@ static int raw_co_create(BlockdevCreateOptions *options, Error **errp)
ddf19c
     return 0;
ddf19c
 }
ddf19c
 
ddf19c
-static int coroutine_fn raw_co_create_opts(const char *filename, QemuOpts *opts,
ddf19c
+static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
ddf19c
+                                           const char *filename,
ddf19c
+                                           QemuOpts *opts,
ddf19c
                                            Error **errp)
ddf19c
 {
ddf19c
     BlockdevCreateOptions options;
ddf19c
diff --git a/block/gluster.c b/block/gluster.c
ddf19c
index 4fa4a77..0aa1f2c 100644
ddf19c
--- a/block/gluster.c
ddf19c
+++ b/block/gluster.c
ddf19c
@@ -1130,7 +1130,8 @@ out:
ddf19c
     return ret;
ddf19c
 }
ddf19c
 
ddf19c
-static int coroutine_fn qemu_gluster_co_create_opts(const char *filename,
ddf19c
+static int coroutine_fn qemu_gluster_co_create_opts(BlockDriver *drv,
ddf19c
+                                                    const char *filename,
ddf19c
                                                     QemuOpts *opts,
ddf19c
                                                     Error **errp)
ddf19c
 {
ddf19c
diff --git a/block/nfs.c b/block/nfs.c
ddf19c
index 9a6311e..cc2413d 100644
ddf19c
--- a/block/nfs.c
ddf19c
+++ b/block/nfs.c
ddf19c
@@ -662,7 +662,9 @@ out:
ddf19c
     return ret;
ddf19c
 }
ddf19c
 
ddf19c
-static int coroutine_fn nfs_file_co_create_opts(const char *url, QemuOpts *opts,
ddf19c
+static int coroutine_fn nfs_file_co_create_opts(BlockDriver *drv,
ddf19c
+                                                const char *url,
ddf19c
+                                                QemuOpts *opts,
ddf19c
                                                 Error **errp)
ddf19c
 {
ddf19c
     BlockdevCreateOptions *create_options;
ddf19c
diff --git a/block/parallels.c b/block/parallels.c
ddf19c
index 7a01997..6d4ed77 100644
ddf19c
--- a/block/parallels.c
ddf19c
+++ b/block/parallels.c
ddf19c
@@ -609,7 +609,8 @@ exit:
ddf19c
     goto out;
ddf19c
 }
ddf19c
 
ddf19c
-static int coroutine_fn parallels_co_create_opts(const char *filename,
ddf19c
+static int coroutine_fn parallels_co_create_opts(BlockDriver *drv,
ddf19c
+                                                 const char *filename,
ddf19c
                                                  QemuOpts *opts,
ddf19c
                                                  Error **errp)
ddf19c
 {
ddf19c
diff --git a/block/qcow.c b/block/qcow.c
ddf19c
index fce8989..8973e4e 100644
ddf19c
--- a/block/qcow.c
ddf19c
+++ b/block/qcow.c
ddf19c
@@ -934,7 +934,8 @@ exit:
ddf19c
     return ret;
ddf19c
 }
ddf19c
 
ddf19c
-static int coroutine_fn qcow_co_create_opts(const char *filename,
ddf19c
+static int coroutine_fn qcow_co_create_opts(BlockDriver *drv,
ddf19c
+                                            const char *filename,
ddf19c
                                             QemuOpts *opts, Error **errp)
ddf19c
 {
ddf19c
     BlockdevCreateOptions *create_options = NULL;
ddf19c
diff --git a/block/qcow2.c b/block/qcow2.c
ddf19c
index 83b1fc0..71067c6 100644
ddf19c
--- a/block/qcow2.c
ddf19c
+++ b/block/qcow2.c
ddf19c
@@ -3558,7 +3558,9 @@ out:
ddf19c
     return ret;
ddf19c
 }
ddf19c
 
ddf19c
-static int coroutine_fn qcow2_co_create_opts(const char *filename, QemuOpts *opts,
ddf19c
+static int coroutine_fn qcow2_co_create_opts(BlockDriver *drv,
ddf19c
+                                             const char *filename,
ddf19c
+                                             QemuOpts *opts,
ddf19c
                                              Error **errp)
ddf19c
 {
ddf19c
     BlockdevCreateOptions *create_options = NULL;
ddf19c
diff --git a/block/qed.c b/block/qed.c
ddf19c
index d8c4e5f..1af9b3c 100644
ddf19c
--- a/block/qed.c
ddf19c
+++ b/block/qed.c
ddf19c
@@ -720,7 +720,8 @@ out:
ddf19c
     return ret;
ddf19c
 }
ddf19c
 
ddf19c
-static int coroutine_fn bdrv_qed_co_create_opts(const char *filename,
ddf19c
+static int coroutine_fn bdrv_qed_co_create_opts(BlockDriver *drv,
ddf19c
+                                                const char *filename,
ddf19c
                                                 QemuOpts *opts,
ddf19c
                                                 Error **errp)
ddf19c
 {
ddf19c
diff --git a/block/raw-format.c b/block/raw-format.c
ddf19c
index 3a76ec7..93b25e1 100644
ddf19c
--- a/block/raw-format.c
ddf19c
+++ b/block/raw-format.c
ddf19c
@@ -419,7 +419,9 @@ static int raw_has_zero_init_truncate(BlockDriverState *bs)
ddf19c
     return bdrv_has_zero_init_truncate(bs->file->bs);
ddf19c
 }
ddf19c
 
ddf19c
-static int coroutine_fn raw_co_create_opts(const char *filename, QemuOpts *opts,
ddf19c
+static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
ddf19c
+                                           const char *filename,
ddf19c
+                                           QemuOpts *opts,
ddf19c
                                            Error **errp)
ddf19c
 {
ddf19c
     return bdrv_create_file(filename, opts, errp);
ddf19c
diff --git a/block/rbd.c b/block/rbd.c
ddf19c
index 027cbcc..8847259 100644
ddf19c
--- a/block/rbd.c
ddf19c
+++ b/block/rbd.c
ddf19c
@@ -425,7 +425,8 @@ static int qemu_rbd_co_create(BlockdevCreateOptions *options, Error **errp)
ddf19c
     return qemu_rbd_do_create(options, NULL, NULL, errp);
ddf19c
 }
ddf19c
 
ddf19c
-static int coroutine_fn qemu_rbd_co_create_opts(const char *filename,
ddf19c
+static int coroutine_fn qemu_rbd_co_create_opts(BlockDriver *drv,
ddf19c
+                                                const char *filename,
ddf19c
                                                 QemuOpts *opts,
ddf19c
                                                 Error **errp)
ddf19c
 {
ddf19c
diff --git a/block/sheepdog.c b/block/sheepdog.c
ddf19c
index cfa8433..a8a7e32 100644
ddf19c
--- a/block/sheepdog.c
ddf19c
+++ b/block/sheepdog.c
ddf19c
@@ -2157,7 +2157,9 @@ out:
ddf19c
     return ret;
ddf19c
 }
ddf19c
 
ddf19c
-static int coroutine_fn sd_co_create_opts(const char *filename, QemuOpts *opts,
ddf19c
+static int coroutine_fn sd_co_create_opts(BlockDriver *drv,
ddf19c
+                                          const char *filename,
ddf19c
+                                          QemuOpts *opts,
ddf19c
                                           Error **errp)
ddf19c
 {
ddf19c
     BlockdevCreateOptions *create_options = NULL;
ddf19c
diff --git a/block/ssh.c b/block/ssh.c
ddf19c
index b4375cf..84e9282 100644
ddf19c
--- a/block/ssh.c
ddf19c
+++ b/block/ssh.c
ddf19c
@@ -963,7 +963,9 @@ fail:
ddf19c
     return ret;
ddf19c
 }
ddf19c
 
ddf19c
-static int coroutine_fn ssh_co_create_opts(const char *filename, QemuOpts *opts,
ddf19c
+static int coroutine_fn ssh_co_create_opts(BlockDriver *drv,
ddf19c
+                                           const char *filename,
ddf19c
+                                           QemuOpts *opts,
ddf19c
                                            Error **errp)
ddf19c
 {
ddf19c
     BlockdevCreateOptions *create_options;
ddf19c
diff --git a/block/vdi.c b/block/vdi.c
ddf19c
index 0142da7..e1a11f2 100644
ddf19c
--- a/block/vdi.c
ddf19c
+++ b/block/vdi.c
ddf19c
@@ -896,7 +896,9 @@ static int coroutine_fn vdi_co_create(BlockdevCreateOptions *create_options,
ddf19c
     return vdi_co_do_create(create_options, DEFAULT_CLUSTER_SIZE, errp);
ddf19c
 }
ddf19c
 
ddf19c
-static int coroutine_fn vdi_co_create_opts(const char *filename, QemuOpts *opts,
ddf19c
+static int coroutine_fn vdi_co_create_opts(BlockDriver *drv,
ddf19c
+                                           const char *filename,
ddf19c
+                                           QemuOpts *opts,
ddf19c
                                            Error **errp)
ddf19c
 {
ddf19c
     QDict *qdict = NULL;
ddf19c
diff --git a/block/vhdx.c b/block/vhdx.c
ddf19c
index f02d261..33e57cd 100644
ddf19c
--- a/block/vhdx.c
ddf19c
+++ b/block/vhdx.c
ddf19c
@@ -2046,7 +2046,8 @@ delete_and_exit:
ddf19c
     return ret;
ddf19c
 }
ddf19c
 
ddf19c
-static int coroutine_fn vhdx_co_create_opts(const char *filename,
ddf19c
+static int coroutine_fn vhdx_co_create_opts(BlockDriver *drv,
ddf19c
+                                            const char *filename,
ddf19c
                                             QemuOpts *opts,
ddf19c
                                             Error **errp)
ddf19c
 {
ddf19c
diff --git a/block/vmdk.c b/block/vmdk.c
ddf19c
index 20e909d..eb726f2 100644
ddf19c
--- a/block/vmdk.c
ddf19c
+++ b/block/vmdk.c
ddf19c
@@ -2588,7 +2588,9 @@ exit:
ddf19c
     return blk;
ddf19c
 }
ddf19c
 
ddf19c
-static int coroutine_fn vmdk_co_create_opts(const char *filename, QemuOpts *opts,
ddf19c
+static int coroutine_fn vmdk_co_create_opts(BlockDriver *drv,
ddf19c
+                                            const char *filename,
ddf19c
+                                            QemuOpts *opts,
ddf19c
                                             Error **errp)
ddf19c
 {
ddf19c
     Error *local_err = NULL;
ddf19c
diff --git a/block/vpc.c b/block/vpc.c
ddf19c
index a655502..6df75e2 100644
ddf19c
--- a/block/vpc.c
ddf19c
+++ b/block/vpc.c
ddf19c
@@ -1089,8 +1089,10 @@ out:
ddf19c
     return ret;
ddf19c
 }
ddf19c
 
ddf19c
-static int coroutine_fn vpc_co_create_opts(const char *filename,
ddf19c
-                                           QemuOpts *opts, Error **errp)
ddf19c
+static int coroutine_fn vpc_co_create_opts(BlockDriver *drv,
ddf19c
+                                           const char *filename,
ddf19c
+                                           QemuOpts *opts,
ddf19c
+                                           Error **errp)
ddf19c
 {
ddf19c
     BlockdevCreateOptions *create_options = NULL;
ddf19c
     QDict *qdict;
ddf19c
diff --git a/include/block/block_int.h b/include/block/block_int.h
ddf19c
index 96e327b..7ff81be 100644
ddf19c
--- a/include/block/block_int.h
ddf19c
+++ b/include/block/block_int.h
ddf19c
@@ -136,7 +136,8 @@ struct BlockDriver {
ddf19c
     void (*bdrv_close)(BlockDriverState *bs);
ddf19c
     int coroutine_fn (*bdrv_co_create)(BlockdevCreateOptions *opts,
ddf19c
                                        Error **errp);
ddf19c
-    int coroutine_fn (*bdrv_co_create_opts)(const char *filename,
ddf19c
+    int coroutine_fn (*bdrv_co_create_opts)(BlockDriver *drv,
ddf19c
+                                            const char *filename,
ddf19c
                                             QemuOpts *opts,
ddf19c
                                             Error **errp);
ddf19c
     int (*bdrv_make_empty)(BlockDriverState *bs);
ddf19c
-- 
ddf19c
1.8.3.1
ddf19c