[Qemu-devel] [PATCH 1/2] block: add dirty flag status to qemu-img
From: Dong Xu Wang wdon...@linux.vnet.ibm.com Some block drivers can verify their image files are clean or not. So we can show it while using qemu-img info CC: Kevin Wolf kw...@redhat.com CC: Stefan Hajnoczi stefa...@linux.vnet.ibm.com Signed-off-by: Dong Xu Wang wdon...@linux.vnet.ibm.com --- Previous discussion can be found at: http://patchwork.ozlabs.org/patch/128730/ block.c | 14 ++ block.h |2 ++ block_int.h |1 + qemu-img.c |3 +++ 4 files changed, 20 insertions(+), 0 deletions(-) diff --git a/block.c b/block.c index 3f072f6..24fd774 100644 --- a/block.c +++ b/block.c @@ -186,6 +186,20 @@ static void bdrv_io_limits_intercept(BlockDriverState *bs, qemu_co_queue_next(bs-throttled_reqs); } +/* check if the image is dirty */ +int bdrv_is_dirty(BlockDriverState *bs) +{ +BlockDriver *drv = bs-drv; + +if (!drv) { +return 0; +} +if (!drv-bdrv_is_dirty) { +return 0; +} +return drv-bdrv_is_dirty(bs); +} + /* check if the path starts with protocol: */ static int path_has_protocol(const char *path) { diff --git a/block.h b/block.h index 3bd4398..e3f3b55 100644 --- a/block.h +++ b/block.h @@ -104,6 +104,8 @@ void bdrv_io_limits_enable(BlockDriverState *bs); void bdrv_io_limits_disable(BlockDriverState *bs); bool bdrv_io_limits_enabled(BlockDriverState *bs); +int bdrv_is_dirty(BlockDriverState *bs); + void bdrv_init(void); void bdrv_init_with_whitelist(void); BlockDriver *bdrv_find_protocol(const char *filename); diff --git a/block_int.h b/block_int.h index 311bd2a..46afffb 100644 --- a/block_int.h +++ b/block_int.h @@ -84,6 +84,7 @@ struct BlockDriver { int (*bdrv_create)(const char *filename, QEMUOptionParameter *options); int (*bdrv_set_key)(BlockDriverState *bs, const char *key); int (*bdrv_make_empty)(BlockDriverState *bs); +int (*bdrv_is_dirty)(BlockDriverState *bs); /* aio */ BlockDriverAIOCB *(*bdrv_aio_readv)(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, diff --git a/qemu-img.c b/qemu-img.c index 01cc0d3..a79c274 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -1153,6 +1153,9 @@ static int img_info(int argc, char **argv) if (bdrv_is_encrypted(bs)) { printf(encrypted: yes\n); } +if (bdrv_is_dirty(bs)) { +printf(dirty,need check: yes\n); +} if (bdrv_get_info(bs, bdi) = 0) { if (bdi.cluster_size != 0) { printf(cluster_size: %d\n, bdi.cluster_size); -- 1.7.5.4
[Qemu-devel] [PATCH 2/2] block: track dirty flag status in qed
From: Dong Xu Wang wdon...@linux.vnet.ibm.com qed driver use QED_F_NEED_CHECK to mark if the image is clean. CC: Kevin Wolf kw...@redhat.com CC: Stefan Hajnoczi stefa...@linux.vnet.ibm.com Signed-off-by: Dong Xu Wang wdon...@linux.vnet.ibm.com --- block/qed.c |7 +++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/block/qed.c b/block/qed.c index 8da3ebe..1e909b1 100644 --- a/block/qed.c +++ b/block/qed.c @@ -1429,6 +1429,12 @@ static int bdrv_qed_check(BlockDriverState *bs, BdrvCheckResult *result) return qed_check(s, result, false); } +static int bdrv_qed_is_dirty(BlockDriverState *bs) +{ +BDRVQEDState *s = bs-opaque; +return s-header.features QED_F_NEED_CHECK; +} + static QEMUOptionParameter qed_create_options[] = { { .name = BLOCK_OPT_SIZE, @@ -1474,6 +1480,7 @@ static BlockDriver bdrv_qed = { .bdrv_get_info= bdrv_qed_get_info, .bdrv_change_backing_file = bdrv_qed_change_backing_file, .bdrv_check = bdrv_qed_check, +.bdrv_is_dirty= bdrv_qed_is_dirty, }; static void bdrv_qed_init(void) -- 1.7.5.4
Re: [Qemu-devel] [PATCH v6] block:add-cow file format
On Fri, Dec 30, 2011 at 22:09, Stefan Hajnoczi stefa...@gmail.com wrote: On Thu, Dec 29, 2011 at 05:36:59PM +0800, Dong Xu Wang wrote: Some comments on everything but the I/O path, which I haven't reviewed yet: diff --git a/block/add-cow.c b/block/add-cow.c new file mode 100644 index 000..95af5b7 --- /dev/null +++ b/block/add-cow.c @@ -0,0 +1,429 @@ Missing GPL or LGPL license header. +#include qemu-common.h +#include block_int.h +#include module.h + +#define ADD_COW_MAGIC (((uint64_t)'A' 56) | ((uint64_t)'D' 48) | \ +((uint64_t)'D' 40) | ((uint64_t)'_' 32) | \ +((uint64_t)'C' 24) | ((uint64_t)'O' 16) | \ +((uint64_t)'W' 8) | 0xFF) +#define ADD_COW_VERSION 1 +#define ADD_COW_FILE_LEN1024 + +typedef struct AddCowHeader { +uint64_tmagic; +uint32_tversion; +charbacking_file[ADD_COW_FILE_LEN]; +charimage_file[ADD_COW_FILE_LEN]; +uint64_tsize; +charreserved[492]; +} QEMU_PACKED AddCowHeader; + +typedef struct BDRVAddCowState { +charimage_file[ADD_COW_FILE_LEN]; Why is this field needed? Yes, not needed. +BlockDriverState*image_hd; +uint8_t *bitmap; +uint64_tbitmap_size; +CoMutex lock; +} BDRVAddCowState; + +static int add_cow_probe(const uint8_t *buf, int buf_size, const char *filename) +{ +const AddCowHeader *header = (const void *)buf; + +if (be64_to_cpu(header-magic) == ADD_COW_MAGIC +be32_to_cpu(header-version) == ADD_COW_VERSION) { +return 100; +} else { +return 0; +} +} + +static int add_cow_open(BlockDriverState *bs, int flags) +{ +AddCowHeaderheader; +int64_t size; +charimage_filename[ADD_COW_FILE_LEN]; +BlockDriver *image_drv = NULL; +int ret; +BDRVAddCowState *s = bs-opaque; +BlockDriverState*backing_bs = NULL; + +ret = bdrv_pread(bs-file, 0, header, sizeof(header)); +if (ret != sizeof(header)) { +goto fail; +} + +if (be64_to_cpu(header.magic) != ADD_COW_MAGIC) { +ret = -EINVAL; +goto fail; +} +if (be32_to_cpu(header.version) != ADD_COW_VERSION) { +char version[64]; +snprintf(version, sizeof(version), ADD-COW version %d, header.version); +qerror_report(QERR_UNKNOWN_BLOCK_FORMAT_FEATURE, +bs-device_name, add-cow, version); +ret = -ENOTSUP; +goto fail; +} + +size = be64_to_cpu(header.size); +bs-total_sectors = size / BDRV_SECTOR_SIZE; + +QEMU_BUILD_BUG_ON(sizeof(bs-backing_file) != sizeof(header.backing_file)); +QEMU_BUILD_BUG_ON(sizeof(s-image_file) != sizeof(header.image_file)); +pstrcpy(bs-backing_file, sizeof(bs-backing_file), +header.backing_file); +pstrcpy(s-image_file, sizeof(s-image_file), +header.image_file); This assumes that header.backing_file and header.image_file is NUL-terminated. If the file happened to have the magic number and version but does not include '\0' bytes in the header.backing_file then we may crash here when trying to read beyond the end of the header struct. Image format code should be robust. Please use strncpy(3) carefully instead of pstrcpy(). Also please update the file format specification to either make these fields NUL-terminated or NUL-terminated unless the length is 1024 characters (in which case there is no NUL but the string still ends). Okay. + +s-bitmap_size = ((bs-total_sectors + 7) 3); +s-bitmap = qemu_blockalign(bs, s-bitmap_size); + +ret = bdrv_pread(bs-file, sizeof(header), s-bitmap, +s-bitmap_size); +if (ret != s-bitmap_size) { +goto fail; +} + +if (s-image_file[0] == '\0') { +ret = -ENOENT; +goto fail; +} + +ret = bdrv_file_open(backing_bs, bs-backing_file, 0); +if (ret 0) { +return ret; +} +bdrv_delete(backing_bs); What does this do? (It leaks s-bitmap when it fails.) I wanna make sure backing_file exists while opening. + +s-image_hd = bdrv_new(); + +if (path_has_protocol(s-image_file)) { +pstrcpy(image_filename, sizeof(image_filename), +s-image_file); +} else { +path_combine(image_filename, sizeof(image_filename), + bs-filename, s-image_file); +} + +image_drv = bdrv_find_format(raw); +ret = bdrv_open(s-image_hd, image_filename, flags, image_drv); +if (ret 0) { +bdrv_delete(s-image_hd); +s-image_hd = NULL; +goto fail; +}
[Qemu-devel] [PATCH V2] Make python mandatory
Make python mandatory. Signed-off-by: Sebastian Herbszt herb...@gmx.de --- configure | 10 +++--- 1 files changed, 3 insertions(+), 7 deletions(-) diff --git a/configure b/configure index 640e815..a54439d 100755 --- a/configure +++ b/configure @@ -1185,13 +1185,9 @@ if test $solaris = yes ; then fi fi -if test $guest_agent != no ; then - if has $python; then -: - else -echo Python not found. Use --python=/path/to/python -exit 1 - fi +if ! has $python; then + echo Python not found. Use --python=/path/to/python + exit 1 fi if test -z $target_list ; then -- 1.7.3.4
Re: [Qemu-devel] [PATCH V2] Make python mandatory
Am 31.12.2011 12:14, schrieb Sebastian Herbszt: Make python mandatory. Signed-off-by: Sebastian Herbszt herb...@gmx.de --- configure | 10 +++--- 1 files changed, 3 insertions(+), 7 deletions(-) diff --git a/configure b/configure index 640e815..a54439d 100755 --- a/configure +++ b/configure @@ -1185,13 +1185,9 @@ if test $solaris = yes ; then fi fi -if test $guest_agent != no ; then - if has $python; then - : - else - echo Python not found. Use --python=/path/to/python - exit 1 - fi +if ! has $python; then + echo Python not found. Use --python=/path/to/python + exit 1 fi if test -z $target_list ; then Reviewed-by: Stefan Weil s...@weilnetz.de Maybe this patch can be applied via qemu-trivial. Regards, Stefan Weil
Re: [Qemu-devel] [PATCH V2] Make python mandatory
On 31 December 2011 11:14, Sebastian Herbszt herb...@gmx.de wrote: +if ! has $python; then + echo Python not found. Use --python=/path/to/python + exit 1 fi This will do the wrong thing if the user runs configure with '--python=/path with spaces/python', but the Makefile won't cope with that either so I guess it's not that important. -- PMM
Re: [Qemu-devel] [PATCH 4/4] target-mips: Fix MIPS_DEBUG.
On 31 December 2011 04:54, Richard Henderson r...@twiddle.net wrote: The macro uses the DisasContext. Pass it around as needed. Signed-off-by: Richard Henderson r...@twiddle.net --- target-mips/translate.c | 80 ++- 1 files changed, 44 insertions(+), 36 deletions(-) diff --git a/target-mips/translate.c b/target-mips/translate.c index 8908c8c..11272b6 100644 --- a/target-mips/translate.c +++ b/target-mips/translate.c @@ -1489,7 +1489,8 @@ static void gen_arith_imm (CPUState *env, DisasContext *ctx, uint32_t opc, } /* Logic with immediate operand */ -static void gen_logic_imm (CPUState *env, uint32_t opc, int rt, int rs, int16_t imm) +static void gen_logic_imm (CPUState *env, DisasContext *ctx, uint32_t opc, + int rt, int rs, int16_t imm) { target_ulong uimm; const char *opn = imm logic; Am I missing something, or does gen_logic_imm() not actually use env at all? Maybe we should be replacing env with ctx in the parameter list in some/most of these functions rather than adding it? (This suggestion is mostly because I kind of like the approach to translate.c that avoids passingn CPUState wherever possible, to reduce the kind of subtle bug where you use something in CPUState that isn't actually valid.) @@ -9919,19 +9922,24 @@ static void gen_ldst_multiple (DisasContext *ctx, uint32_t opc, int reglist, switch (opc) { case LWM32: gen_helper_lwm(t0, t1, t2); + opn = lwm; break; case SWM32: gen_helper_swm(t0, t1, t2); + opn = swm; break; #ifdef TARGET_MIPS64 case LDM: gen_helper_ldm(t0, t1, t2); + opn = ldm; break; case SDM: gen_helper_sdm(t0, t1, t2); + opn = sdm; break; #endif } + (void)opn; MIPS_DEBUG(%s, %x, %d(%s), opn, reglist, offset, regnames[base]); tcg_temp_free(t0); tcg_temp_free(t1); Maybe this bit should be split out from the bulk of the just add ctx to function signatures and calls mechanical change? -- PMM
Re: [Qemu-devel] [PATCH 2/3] target-mips:enabling of 64 bit user mode and floating point operations MIPS_HFLAG_UX is included in env-hflags so that the address computation for LD instruction does not
Am 31.12.2011 08:42, schrieb Khansa Butt: On Fri, Dec 9, 2011 at 5:04 AM, Andreas Färber andreas.faer...@web.de wrote: Am 08.12.2011 06:25, schrieb kha...@kics.edu.pk: diff --git a/target-mips/translate.c b/target-mips/translate.c index d5b1c76..452a63b 100644 --- a/target-mips/translate.c +++ b/target-mips/translate.c @@ -12779,6 +12779,10 @@ void cpu_reset (CPUMIPSState *env) env-hflags |= MIPS_HFLAG_FPU; } #ifdef TARGET_MIPS64 +env-hflags |= MIPS_HFLAG_UX; So for those of us not knowing mips, it's defined as: #define MIPS_HFLAG_UX 0x00200 /* 64-bit user mode */ The code above is inside CONFIG_USER_ONLY, so this looks right for n64 but not for n32 ABI. If you put this into its own patch with a description of ---8--- target-mips: Enable 64 bit user mode for n64 For user mode n64 ABI emulation, MIPS_HFLAG_UX is included in env-hflags so that the address computation for LD instruction does not get treated as 32 bit code, see gen_op_addr_add() in translate.c. Signed-off-by: Abdul Qadeer qad...@kics.edu.pk Signed-off-by: (you) ---8--- and make it depend on TARGET_ABI_MIPSN64 then I will happily add my Acked-by. Why this is necessary to put env-hflags |= MIPS_HFLAG_UX; line under TARGET_ABI_MIPSN64? as this was already put under #if TARGET_MIPS64, is not it suffient? You're right. I was under the impression that both n32 and n64 were based off mips64, but mipsn32 is in fact based off mips. Adding NUBI64 support (as opposed to NUBI64W) would then probably be based off mips as well then. Quite confusing. So yes, no need to add #if defined(TARGET_ABI_MIPSN64) there, but do put it in its own patch with a description explaining why. Andreas
Re: [Qemu-devel] [PATCH 4/4] target-mips: Fix MIPS_DEBUG.
Am 31.12.2011 05:54, schrieb Richard Henderson: The macro uses the DisasContext. Pass it around as needed. This fixes a build failure, right? Order it first then? Since there's no cover letter, series looks mostly good. Some minor comments. Signed-off-by: Richard Henderson r...@twiddle.net --- target-mips/translate.c | 80 ++- 1 files changed, 44 insertions(+), 36 deletions(-) diff --git a/target-mips/translate.c b/target-mips/translate.c index 8908c8c..11272b6 100644 --- a/target-mips/translate.c +++ b/target-mips/translate.c @@ -1489,7 +1489,8 @@ static void gen_arith_imm (CPUState *env, DisasContext *ctx, uint32_t opc, } /* Logic with immediate operand */ -static void gen_logic_imm (CPUState *env, uint32_t opc, int rt, int rs, int16_t imm) +static void gen_logic_imm (CPUState *env, DisasContext *ctx, uint32_t opc, + int rt, int rs, int16_t imm) When you touch the declaration, please fix Coding Style by removing the extra space before the bracket. Applies to 1-4. Andreas -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
[Qemu-devel] Mixed USB 1.1 and USB 2.0 on the same port
Hi all, how can I use a USB 1.1 device on the USB 2.0 bus? Currently the EHCI implementation complains that the device is mismatches the USB version. I want to offer one root port for both USB 2.0 and USB 1.1 devices using usb-host,... Routings to the guest. Maybe only some parameters need to be added to the qemu commandline? Any hint would be helpful. Thanks. Best regards, Erik
[Qemu-devel] [Bug 897771] Re: qemu 1.0-rc4 no longer able to boot NetBSD-current/i386
I found the cause of the regression. As as Stefan Weil already figured, it was caused by the following commit: commit d0ed8076cbdc26138a7e33fed5e45a35d019a103 Author: Avi Kivity a...@redhat.com Date: Sun Jul 24 17:47:18 2011 +0300 pci_host: convert conf index and data ports to memory API Reviewed-by: Richard Henderson r...@twiddle.net Signed-off-by: Avi Kivity a...@redhat.com This commit incorrectly changed the emulation of the PCI configuration register at I/O port 0xCF8. Before the commit, an outb to port 0xCFB or an outw to port 0xCFA had no effect, but after the commit, they change the value of the CONFIG_ADDRESS DWORD register at 0xCF8. This is contrary to the behavior of real PC hardware, and contrary to the PCI standard which clearly states that the only I/O space consumed by the CONFIG_ADDRESS register is the DWORD at address 0xCF8. Changing pci_host_config_write() to ignore writes with addr != 0 is sufficient for qemu to again be able to boot NetBSD. For full compliance with the PCI standard, it should also ignore writes with size != 4, and a similar change should probably also be made to pci_host_config_read(). -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/897771 Title: qemu 1.0-rc4 no longer able to boot NetBSD-current/i386 Status in QEMU: Confirmed Bug description: Booting a NetBSD-current/i386 install CD using qemu 1.0-rc4 fails. The same CD does boot in earlier versions of qemu, for example, 0.11.0. To reproduce, download the http://www.gson.org/netbsd/bugs/qemu/boot-com-20270050Z.iso and attempt to boot it with: qemu -nographic -cdrom boot-com-20270050Z.iso This fails with a guest kernel panic: NetBSD 5.99.57 (GENERIC) #0: Sun Nov 27 07:41:56 UTC 2011 bui...@b8.netbsd.org:/home/builds/ab/HEAD/i386/20270050Z-obj/home/builds/ab/HEAD/src/sys/arch/i386/compile/GENERIC total memory = 127 MB avail memory = 112 MB cprng kernel: WARNING insufficient entropy at creation. mainbus0 (root) cpu0 at mainbus0 apid 0: QEMU Virtual CPU version 0.15.93, id 0x633 ioapic0 at mainbus0 apid 1 acpi0 at mainbus0: Intel ACPICA 20110623 panic: pci_make_tag: bad request fatal breakpoint trap in supervisor mode trap type 1 code 0 eip c0269b04 cs 8 eflags 282 cr2 0 ilevel 8 Stopped in pid 0.1 (system) at netbsd:breakpoint+0x4: popl%ebp db{0} t breakpoint(c0c04c75,c0cc2f80,c0bc91a4,c0e358e4,2,c11b70d6,c0e35908,c053999d,c0cdef20,0) at netbsd:breakpoint+0x4 vpanic(c0bc91a4,c0e358e4,c117d068,f,c11e6fcc,0,c0e35918,c0665969,c0bc91a4,c0b1bf4c) at netbsd:vpanic+0x1e2 printf_nolog(c0bc91a4,c0b1bf4c,c0e35908,c010d957,8,c0c1f2c0,0,0,c0d08e20,0) at netbsd:printf_nolog pci_decompose_tag(c0e3599c,0,0,10,0,ca675898,c0e35988,c0d08e20,c11b9200,0) at netbsd:pci_decompose_tag acpi_pci_link_add_reference(c12011c0,0,0,10,0,ca41eb90,0,3,0,4) at netbsd:acpi_pci_link_add_reference+0xb2 mpacpi_find_interrupts(ca41eb90,c0116a4a,c0116a5e,0,ca41eb90,c0e35b50,c0e35aa8,c01180c7,c,c0116a4a) at netbsd:mpacpi_find_interrupts+0x5ea acpi_md_callback(c,c0116a4a,c0116a5e,0,1,ca3fd7cc,1,c078e2e4,c0cb6ce0,ca435ea0) at netbsd:acpi_md_callback+0x1c acpi_attach(ca660500,ca660d00,c0e35b50,0,c0e35b50,80,f,10,c0b5dcd9,c0e35b42) at netbsd:acpi_attach+0x14a config_attach_loc(ca660500,c0c1d7a0,0,c0e35b50,0,0,2589,58421301,4350,53445842) at netbsd:config_attach_loc+0x176 config_found_ia(ca660500,c0b59f3c,c0e35b50,0,4f424101,20534843,80,f,c0c2bbe0,c0c2bc00) at netbsd:config_found_ia+0x36 mainbus_rescan(ca660500,c0b59f3c,0,ca660500,c0cb6ce0,c0bd71ce,c0e35bd8,c093575c,ca437f28,c0b8e0a1) at netbsd:mainbus_rescan+0x1c2 mainbus_attach(0,ca660500,0,c078f4b7,c0b59187,c0b59187,636f4200,7368,3001403,101) at netbsd:mainbus_attach+0xb4 config_attach_loc(0,c0c1bbb0,0,0,0,7368,f10,0,c0b59187,e3b000) at netbsd:config_attach_loc+0x176 config_attach(0,c0c1bbb0,0,0,1984,c0cc5680,c0e35cd8,c01f224e,c0b59187,0) at netbsd:config_attach+0x2e config_rootfound(c0b59187,0,0,8,1984,1984,c0e35d40,c04b78d8,c0ba59a1,6) at netbsd:config_rootfound+0x42 cpu_configure(c0ba59a1,6,3,0,,f9b00,,f9300,0,0) at netbsd:cpu_configure+0x2a main(0,0,0,0,0,0,0,0,0,0) at netbsd:main+0x2ba db{0} To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/897771/+subscriptions
Re: [Qemu-devel] [PATCH 4/4] target-mips: Fix MIPS_DEBUG.
On 12/31/2011 10:50 PM, Peter Maydell wrote: +static void gen_logic_imm (CPUState *env, DisasContext *ctx, uint32_t opc, + int rt, int rs, int16_t imm) { target_ulong uimm; const char *opn = imm logic; Am I missing something, or does gen_logic_imm() not actually use env at all? Maybe we should be replacing env with ctx in the parameter list in some/most of these functions rather than adding it? You're not missing anything. Really, env should not be used by anything in that file except for the outermost gen_intermediate_code_internal, which already copies the bits that are needed to the ctx. Cleaning up incorrect uses of env throughout that file is a larger job. r~