diff mbox

[RFC,for-3.0,4/4] block/qcow2-rust: Register block driver

Message ID 20170401155751.14322-5-mreitz@redhat.com
State New
Headers show

Commit Message

Max Reitz April 1, 2017, 3:57 p.m. UTC
The rust qcow2 driver is now actually MUCH BETTER than the LEGACY
CROOKED qcow2 driver, so let's not beat around the bush and just
register it as a block driver. Has always been my opinion, never said
anything different. The QEMU project will deal with the C issue in a
decisive way. Q.M.U.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 block/Makefile.objs |  1 +
 block/qcow2-rust.c  | 38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+)
 create mode 100644 block/qcow2-rust.c

Comments

Fam Zheng April 19, 2017, 11:28 a.m. UTC | #1
On Sat, 04/01 17:57, Max Reitz wrote:
> +/* This is just for the module loading system to detect this driver */
> +static BlockDriver _ __attribute__((used)) = {
> +    .format_name = "qcow2-rust",
> +};

You see why I didn't like that system in the first place.

Fam
Max Reitz April 19, 2017, 12:19 p.m. UTC | #2
On 19.04.2017 13:28, Fam Zheng wrote:
> On Sat, 04/01 17:57, Max Reitz wrote:
>> +/* This is just for the module loading system to detect this driver */
>> +static BlockDriver _ __attribute__((used)) = {
>> +    .format_name = "qcow2-rust",
>> +};
> 
> You see why I didn't like that system in the first place.

Yes. We will have to adjust the module loading system before 3.0, but
I'm confident we can port all block drivers to Rust by then so this will
be a matter of course.

OTOH, why would you ever not load the rust block driver? In the final
version, we'd call it "qcow2", throw the legacy driver out and not even
care about whether the module system detects this one (because it'll be
statically linked anyway).

(Honestly, I think this is just an artifact from beginning of last week
where I wanted to make this driver a module... Beware, my April Fool's
patches may not be polished.)

Max
diff mbox

Patch

diff --git a/block/Makefile.objs b/block/Makefile.objs
index de96f8ee80..4802946e4e 100644
--- a/block/Makefile.objs
+++ b/block/Makefile.objs
@@ -24,6 +24,7 @@  block-obj-y += accounting.o dirty-bitmap.o
 block-obj-y += write-threshold.o
 block-obj-y += backup.o
 block-obj-$(CONFIG_REPLICATION) += replication.o
+block-obj-y += qcow2-rust.o
 
 block-obj-y += crypto.o
 
diff --git a/block/qcow2-rust.c b/block/qcow2-rust.c
new file mode 100644
index 0000000000..1465fa9fe1
--- /dev/null
+++ b/block/qcow2-rust.c
@@ -0,0 +1,38 @@ 
+/* C basis of the Rust qcow2 block driver
+ *
+ * Copyright (C) 2017 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "qemu/osdep.h"
+#include "block/block_int.h"
+#include "qapi/error.h"
+#include "qemu/option.h"
+
+
+/* This is just for the module loading system to detect this driver */
+static BlockDriver _ __attribute__((used)) = {
+    .format_name = "qcow2-rust",
+};
+
+
+extern void bdrv_qcow2_rust_init(void);
+
+block_init(bdrv_qcow2_rust_init);