[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 04/32] blockdev: Move bochs probe into separa
From: |
Max Reitz |
Subject: |
Re: [Qemu-devel] [PATCH v3 04/32] blockdev: Move bochs probe into separate file |
Date: |
Wed, 6 Jul 2016 16:19:05 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 |
On 05.07.2016 17:24, Colin Lord wrote:
> This puts the bochs probe function into its own separate file as part of
> the process of modularizing block drivers. Having the probe functions
> separate from the rest of the driver allows us to probe without having
> to potentially unnecessarily load the driver.
>
> Signed-off-by: Colin Lord <address@hidden>
> ---
> block/Makefile.objs | 1 +
> block/bochs.c | 55
> ++------------------------------------------
> block/probe/bochs.c | 21 +++++++++++++++++
> include/block/driver/bochs.h | 40 ++++++++++++++++++++++++++++++++
> include/block/probe.h | 6 +++++
> 5 files changed, 70 insertions(+), 53 deletions(-)
> create mode 100644 block/probe/bochs.c
> create mode 100644 include/block/driver/bochs.h
> create mode 100644 include/block/probe.h
>
[...]
> diff --git a/block/probe/bochs.c b/block/probe/bochs.c
> new file mode 100644
> index 0000000..8adc09f
> --- /dev/null
> +++ b/block/probe/bochs.c
> @@ -0,0 +1,21 @@
> +#include "qemu/osdep.h"
> +#include "block/block_int.h"
> +#include "block/probe.h"
> +#include "block/driver/bochs.h"
> +
> +int bochs_probe(const uint8_t *buf, int buf_size, const char *filename)
> +{
> + const struct bochs_header *bochs = (const void *)buf;
> +
> + if (buf_size < HEADER_SIZE)
> + return 0;
> +
> + if (!strcmp(bochs->magic, HEADER_MAGIC) &&
> + !strcmp(bochs->type, REDOLOG_TYPE) &&
> + !strcmp(bochs->subtype, GROWING_TYPE) &&
> + ((le32_to_cpu(bochs->version) == HEADER_VERSION) ||
> + (le32_to_cpu(bochs->version) == HEADER_V1)))
> + return 100;
> +
> + return 0;
> +}
Not sure what to do about the coding style here. Some people prefer code
movement to be pure, but I feel bad about doing code movement and then
leaving the code wrongly formatted. That is, in my opinion, every patch
should pass checkpatch.pl (but I won't object to a patch that doesn't
pass checkpatch.pl simply because of pre-existing code).
> diff --git a/include/block/driver/bochs.h b/include/block/driver/bochs.h
> new file mode 100644
> index 0000000..cd87256
> --- /dev/null
> +++ b/include/block/driver/bochs.h
Kevin's point that we maybe should just put this into block/ itself
(just like block/qcow2.h) is not a bad one, but I'm fine either way.
> @@ -0,0 +1,40 @@
> +#ifndef BOCHS_H
> +#define BOCHS_H
Maybe BLOCK_BOCHS_H would be better, considering that Bochs is primarily
a system emulator and its image format doesn't really have an own name.
(Compare block/qcow2.h, which uses BLOCK_QCOW2_H.)
Independently of what you decide to do in any of these three places:
Reviewed-by: Max Reitz <address@hidden>
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-devel] [Qemu-block] [PATCH v3 04/32] blockdev: Move bochs probe into separate file, (continued)
- Re: [Qemu-devel] [PATCH v3 04/32] blockdev: Move bochs probe into separate file, Paolo Bonzini, 2016/07/07
- Re: [Qemu-devel] [PATCH v3 04/32] blockdev: Move bochs probe into separate file, John Snow, 2016/07/07
- Re: [Qemu-devel] [PATCH v3 04/32] blockdev: Move bochs probe into separate file, Kevin Wolf, 2016/07/08
- Re: [Qemu-devel] [Qemu-block] [PATCH v3 04/32] blockdev: Move bochs probe into separate file, Colin Lord, 2016/07/07
- Re: [Qemu-devel] [Qemu-block] [PATCH v3 04/32] blockdev: Move bochs probe into separate file, Kevin Wolf, 2016/07/08
- Re: [Qemu-devel] [Qemu-block] [PATCH v3 04/32] blockdev: Move bochs probe into separate file, Markus Armbruster, 2016/07/08
- Re: [Qemu-devel] [PATCH v3 04/32] blockdev: Move bochs probe into separate file, Paolo Bonzini, 2016/07/07
Re: [Qemu-devel] [PATCH v3 04/32] blockdev: Move bochs probe into separate file,
Max Reitz <=
[Qemu-devel] [PATCH v3 05/32] blockdev: Move cloop probe to its own file, Colin Lord, 2016/07/05
[Qemu-devel] [PATCH v3 03/32] blockdev: Add dynamic module loading for block drivers, Colin Lord, 2016/07/05
[Qemu-devel] [PATCH v3 01/32] blockdev: prepare iSCSI block driver for dynamic loading, Colin Lord, 2016/07/05
[Qemu-devel] [PATCH v3 12/32] blockdev: Move raw probe to its own file, Colin Lord, 2016/07/05
[Qemu-devel] [PATCH v3 10/32] blockdev: Move qcow2 probe to its own file, Colin Lord, 2016/07/05