diff options
-rw-r--r-- | CODING_STYLE | 47 | ||||
-rw-r--r-- | Makefile | 11 | ||||
-rwxr-xr-x | configure | 5 | ||||
-rw-r--r-- | hw/net/pcnet.c | 4 | ||||
-rw-r--r-- | hw/sparc/leon3.c | 4 | ||||
-rw-r--r-- | include/block/nbd.h | 38 | ||||
-rw-r--r-- | include/exec/cpu-common.h | 3 | ||||
-rw-r--r-- | net/net.c | 7 | ||||
-rw-r--r-- | qemu-ga.texi | 4 | ||||
-rw-r--r-- | qemu-nbd.c | 46 | ||||
-rw-r--r-- | qom/object.c | 2 | ||||
m--------- | slirp | 0 | ||||
-rw-r--r-- | tests/qemu-iotests/059.out | 8 | ||||
-rw-r--r-- | tests/qemu-iotests/083.out | 68 | ||||
-rw-r--r-- | tests/qemu-iotests/092.out | 24 | ||||
-rwxr-xr-x | tests/qemu-iotests/182 | 22 | ||||
-rw-r--r-- | tests/qemu-iotests/182.out | 1 | ||||
-rwxr-xr-x | tests/qemu-iotests/221 | 10 | ||||
-rw-r--r-- | tests/qemu-iotests/221.out | 20 | ||||
-rwxr-xr-x | tests/qemu-iotests/233 | 6 | ||||
-rw-r--r-- | tests/qemu-iotests/233.out | 4 | ||||
-rw-r--r-- | util/qemu-sockets.c | 12 |
22 files changed, 206 insertions, 140 deletions
diff --git a/CODING_STYLE b/CODING_STYLE index ec075dedc4..cb8edcbb36 100644 --- a/CODING_STYLE +++ b/CODING_STYLE @@ -29,6 +29,45 @@ Spaces of course are superior to tabs because: Do not leave whitespace dangling off the ends of lines. +1.1 Multiline Indent + +There are several places where indent is necessary: + + - if/else + - while/for + - function definition & call + +When breaking up a long line to fit within line width, we need a proper indent +for the following lines. + +In case of if/else, while/for, align the secondary lines just after the +opening parenthesis of the first. + +For example: + + if (a == 1 && + b == 2) { + + while (a == 1 && + b == 2) { + +In case of function, there are several variants: + + * 4 spaces indent from the beginning + * align the secondary lines just after the opening parenthesis of the + first + +For example: + + do_something(x, y, + z); + + do_something(x, y, + z); + + do_something(x, do_another(y, + z)); + 2. Line width Lines should be 80 characters; try not to make them longer. @@ -108,10 +147,10 @@ block to a separate function altogether. When comparing a variable for (in)equality with a constant, list the constant on the right, as in: -if (a == 1) { - /* Reads like: "If a equals 1" */ - do_something(); -} + if (a == 1) { + /* Reads like: "If a equals 1" */ + do_something(); + } Rationale: Yoda conditions (as in 'if (1 == a)') are awkward to read. Besides, good compilers already warn users when '==' is mis-typed as '=', @@ -639,7 +639,7 @@ clean: ! -path ./roms/edk2/BaseTools/Source/Python/UPT/Dll/sqlite3.dll \ -exec rm {} + rm -f $(edk2-decompressed) - rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) qemu-ga TAGS cscope.* *.pod *~ */*~ + rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) qemu-ga$(EXESUF) TAGS cscope.* *.pod *~ */*~ rm -f fsdev/*.pod scsi/*.pod rm -f qemu-img-cmds.h rm -f ui/shader/*-vert.h ui/shader/*-frag.h @@ -899,11 +899,14 @@ ui/shader.o: $(SRC_PATH)/ui/shader.c \ MAKEINFO=makeinfo MAKEINFOINCLUDES= -I docs -I $(<D) -I $(@D) MAKEINFOFLAGS=--no-split --number-sections $(MAKEINFOINCLUDES) -TEXI2PODFLAGS=$(MAKEINFOINCLUDES) "-DVERSION=$(VERSION)" +TEXI2PODFLAGS=$(MAKEINFOINCLUDES) -DVERSION="$(VERSION)" -DCONFDIR="$(qemu_confdir)" TEXI2PDFFLAGS=$(if $(V),,--quiet) -I $(SRC_PATH) $(MAKEINFOINCLUDES) -docs/version.texi: $(SRC_PATH)/VERSION - $(call quiet-command,echo "@set VERSION $(VERSION)" > $@,"GEN","$@") +docs/version.texi: $(SRC_PATH)/VERSION config-host.mak + $(call quiet-command,(\ + echo "@set VERSION $(VERSION)" && \ + echo "@set CONFDIR $(qemu_confdir)" \ + )> $@,"GEN","$@") %.html: %.texi docs/version.texi $(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers \ @@ -2937,9 +2937,9 @@ if test "$auth_pam" != "no"; then int main(void) { const char *service_name = "qemu"; const char *user = "frank"; - const struct pam_conv *pam_conv = NULL; + const struct pam_conv pam_conv = { 0 }; pam_handle_t *pamh = NULL; - pam_start(service_name, user, pam_conv, &pamh); + pam_start(service_name, user, &pam_conv, &pamh); return 0; } EOF @@ -7882,7 +7882,6 @@ LINKS="$LINKS python" for bios_file in \ $source_path/pc-bios/*.bin \ $source_path/pc-bios/*.lid \ - $source_path/pc-bios/*.aml \ $source_path/pc-bios/*.rom \ $source_path/pc-bios/*.dtb \ $source_path/pc-bios/*.img \ diff --git a/hw/net/pcnet.c b/hw/net/pcnet.c index d9ba04bdfc..16683091c9 100644 --- a/hw/net/pcnet.c +++ b/hw/net/pcnet.c @@ -36,6 +36,7 @@ */ #include "qemu/osdep.h" +#include "qemu/log.h" #include "hw/qdev.h" #include "net/net.h" #include "net/eth.h" @@ -1501,7 +1502,8 @@ static void pcnet_bcr_writew(PCNetState *s, uint32_t rap, uint32_t val) val |= 0x0300; break; default: - printf("Bad SWSTYLE=0x%02x\n", val & 0xff); + qemu_log_mask(LOG_GUEST_ERROR, "pcnet: Bad SWSTYLE=0x%02x\n", + val & 0xff); val = 0x0200; break; } diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c index 774639af33..0383b17c29 100644 --- a/hw/sparc/leon3.c +++ b/hw/sparc/leon3.c @@ -194,6 +194,10 @@ static void leon3_generic_hw_init(MachineState *machine) &entry, NULL, NULL, 1 /* big endian */, EM_SPARC, 0, 0); if (kernel_size < 0) { + kernel_size = load_uimage(kernel_filename, NULL, &entry, + NULL, NULL, NULL); + } + if (kernel_size < 0) { error_report("could not load kernel '%s'", kernel_filename); exit(1); } diff --git a/include/block/nbd.h b/include/block/nbd.h index 6d05983a55..bb9f5bc021 100644 --- a/include/block/nbd.h +++ b/include/block/nbd.h @@ -127,18 +127,32 @@ typedef struct NBDExtent { /* Transmission (export) flags: sent from server to client during handshake, but describe what will happen during transmission */ -#define NBD_FLAG_HAS_FLAGS (1 << 0) /* Flags are there */ -#define NBD_FLAG_READ_ONLY (1 << 1) /* Device is read-only */ -#define NBD_FLAG_SEND_FLUSH (1 << 2) /* Send FLUSH */ -#define NBD_FLAG_SEND_FUA (1 << 3) /* Send FUA (Force Unit Access) */ -#define NBD_FLAG_ROTATIONAL (1 << 4) /* Use elevator algorithm - - rotational media */ -#define NBD_FLAG_SEND_TRIM (1 << 5) /* Send TRIM (discard) */ -#define NBD_FLAG_SEND_WRITE_ZEROES (1 << 6) /* Send WRITE_ZEROES */ -#define NBD_FLAG_SEND_DF (1 << 7) /* Send DF (Do not Fragment) */ -#define NBD_FLAG_CAN_MULTI_CONN (1 << 8) /* Multi-client cache consistent */ -#define NBD_FLAG_SEND_RESIZE (1 << 9) /* Send resize */ -#define NBD_FLAG_SEND_CACHE (1 << 10) /* Send CACHE (prefetch) */ +enum { + NBD_FLAG_HAS_FLAGS_BIT = 0, /* Flags are there */ + NBD_FLAG_READ_ONLY_BIT = 1, /* Device is read-only */ + NBD_FLAG_SEND_FLUSH_BIT = 2, /* Send FLUSH */ + NBD_FLAG_SEND_FUA_BIT = 3, /* Send FUA (Force Unit Access) */ + NBD_FLAG_ROTATIONAL_BIT = 4, /* Use elevator algorithm - + rotational media */ + NBD_FLAG_SEND_TRIM_BIT = 5, /* Send TRIM (discard) */ + NBD_FLAG_SEND_WRITE_ZEROES_BIT = 6, /* Send WRITE_ZEROES */ + NBD_FLAG_SEND_DF_BIT = 7, /* Send DF (Do not Fragment) */ + NBD_FLAG_CAN_MULTI_CONN_BIT = 8, /* Multi-client cache consistent */ + NBD_FLAG_SEND_RESIZE_BIT = 9, /* Send resize */ + NBD_FLAG_SEND_CACHE_BIT = 10, /* Send CACHE (prefetch) */ +}; + +#define NBD_FLAG_HAS_FLAGS (1 << NBD_FLAG_HAS_FLAGS_BIT) +#define NBD_FLAG_READ_ONLY (1 << NBD_FLAG_READ_ONLY_BIT) +#define NBD_FLAG_SEND_FLUSH (1 << NBD_FLAG_SEND_FLUSH_BIT) +#define NBD_FLAG_SEND_FUA (1 << NBD_FLAG_SEND_FUA_BIT) +#define NBD_FLAG_ROTATIONAL (1 << NBD_FLAG_ROTATIONAL_BIT) +#define NBD_FLAG_SEND_TRIM (1 << NBD_FLAG_SEND_TRIM_BIT) +#define NBD_FLAG_SEND_WRITE_ZEROES (1 << NBD_FLAG_SEND_WRITE_ZEROES_BIT) +#define NBD_FLAG_SEND_DF (1 << NBD_FLAG_SEND_DF_BIT) +#define NBD_FLAG_CAN_MULTI_CONN (1 << NBD_FLAG_CAN_MULTI_CONN_BIT) +#define NBD_FLAG_SEND_RESIZE (1 << NBD_FLAG_SEND_RESIZE_BIT) +#define NBD_FLAG_SEND_CACHE (1 << NBD_FLAG_SEND_CACHE_BIT) /* New-style handshake (global) flags, sent from server to client, and control what will happen during handshake phase. */ diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index 848a4b94ab..f7dbe75fbc 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -7,9 +7,6 @@ #include "exec/hwaddr.h" #endif -#include "qemu/bswap.h" -#include "qemu/queue.h" - /* The CPU list lock nests outside page_(un)lock or mmap_(un)lock */ void qemu_init_cpu_list(void); void cpu_list_lock(void); @@ -837,9 +837,10 @@ int qemu_show_nic_models(const char *arg, const char *const *models) return 0; } - fprintf(stderr, "qemu: Supported NIC models: "); - for (i = 0 ; models[i]; i++) - fprintf(stderr, "%s%c", models[i], models[i+1] ? ',' : '\n'); + printf("Supported NIC models:\n"); + for (i = 0 ; models[i]; i++) { + printf("%s\n", models[i]); + } return 1; } diff --git a/qemu-ga.texi b/qemu-ga.texi index 4c7a8fd163..f00ad830f2 100644 --- a/qemu-ga.texi +++ b/qemu-ga.texi @@ -30,7 +30,7 @@ set user's password @end itemize qemu-ga will read a system configuration file on startup (located at -@file{/etc/qemu/qemu-ga.conf} by default), then parse remaining +@file{@value{CONFDIR}/qemu-ga.conf} by default), then parse remaining configuration options on the command line. For the same key, the last option wins, but the lists accumulate (see below for configuration file format). @@ -58,7 +58,7 @@ file format). Enable fsfreeze hook. Accepts an optional argument that specifies script to run on freeze/thaw. Script will be called with 'freeze'/'thaw' arguments accordingly (default is - @samp{/etc/qemu/fsfreeze-hook}). If using -F with an argument, do + @samp{@value{CONFDIR}/fsfreeze-hook}). If using -F with an argument, do not follow -F with a space (for example: @samp{-F/var/run/fsfreezehook.sh}). diff --git a/qemu-nbd.c b/qemu-nbd.c index dca9e72cee..081fcf74d5 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -279,37 +279,25 @@ static int qemu_nbd_client_list(SocketAddress *saddr, QCryptoTLSCreds *tls, printf(" description: %s\n", list[i].description); } if (list[i].flags & NBD_FLAG_HAS_FLAGS) { + static const char *const flag_names[] = { + [NBD_FLAG_READ_ONLY_BIT] = "readonly", + [NBD_FLAG_SEND_FLUSH_BIT] = "flush", + [NBD_FLAG_SEND_FUA_BIT] = "fua", + [NBD_FLAG_ROTATIONAL_BIT] = "rotational", + [NBD_FLAG_SEND_TRIM_BIT] = "trim", + [NBD_FLAG_SEND_WRITE_ZEROES_BIT] = "zeroes", + [NBD_FLAG_SEND_DF_BIT] = "df", + [NBD_FLAG_CAN_MULTI_CONN_BIT] = "multi", + [NBD_FLAG_SEND_RESIZE_BIT] = "resize", + [NBD_FLAG_SEND_CACHE_BIT] = "cache", + }; + printf(" size: %" PRIu64 "\n", list[i].size); printf(" flags: 0x%x (", list[i].flags); - if (list[i].flags & NBD_FLAG_READ_ONLY) { - printf(" readonly"); - } - if (list[i].flags & NBD_FLAG_SEND_FLUSH) { - printf(" flush"); - } - if (list[i].flags & NBD_FLAG_SEND_FUA) { - printf(" fua"); - } - if (list[i].flags & NBD_FLAG_ROTATIONAL) { - printf(" rotational"); - } - if (list[i].flags & NBD_FLAG_SEND_TRIM) { - printf(" trim"); - } - if (list[i].flags & NBD_FLAG_SEND_WRITE_ZEROES) { - printf(" zeroes"); - } - if (list[i].flags & NBD_FLAG_SEND_DF) { - printf(" df"); - } - if (list[i].flags & NBD_FLAG_CAN_MULTI_CONN) { - printf(" multi"); - } - if (list[i].flags & NBD_FLAG_SEND_RESIZE) { - printf(" resize"); - } - if (list[i].flags & NBD_FLAG_SEND_CACHE) { - printf(" cache"); + for (size_t bit = 0; bit < ARRAY_SIZE(flag_names); bit++) { + if (flag_names[bit] && (list[i].flags & (1 << bit))) { + printf(" %s", flag_names[bit]); + } } printf(" )\n"); } diff --git a/qom/object.c b/qom/object.c index e3206d6799..d3412e7fdc 100644 --- a/qom/object.c +++ b/qom/object.c @@ -679,7 +679,7 @@ Object *object_new_with_propv(const char *typename, error_setg(errp, "object type '%s' is abstract", typename); return NULL; } - obj = object_new(typename); + obj = object_new_with_type(klass->type); if (object_set_propv(obj, &local_err, vargs) < 0) { goto error; diff --git a/slirp b/slirp -Subproject 0e79ba48567ccfb3cc2cf2e98cce8811eee7e45 +Subproject f0da6726207b740f6101028b2992f918477a4b0 diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out index 700ad1f290..f51394ae8e 100644 --- a/tests/qemu-iotests/059.out +++ b/tests/qemu-iotests/059.out @@ -2,15 +2,15 @@ QA output created by 059 === Testing invalid granularity === Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 -can't open device TEST_DIR/t.vmdk: Invalid granularity, image may be corrupt +qemu-io: can't open device TEST_DIR/t.vmdk: Invalid granularity, image may be corrupt === Testing too big L2 table size === Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 -can't open device TEST_DIR/t.vmdk: L2 table size too big +qemu-io: can't open device TEST_DIR/t.vmdk: L2 table size too big === Testing too big L1 table size === Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 -can't open device TEST_DIR/t.vmdk: L1 size too big +qemu-io: can't open device TEST_DIR/t.vmdk: L1 size too big === Testing monolithicFlat creation and opening === Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 subformat=monolithicFlat @@ -2050,7 +2050,7 @@ wrote 512/512 bytes at offset 10240 === Testing monolithicFlat with internally generated JSON file name === Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 subformat=monolithicFlat -can't open: Cannot use relative extent paths with VMDK descriptor file 'json:{"image": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, "driver": "blkdebug", "inject-error.0.event": "read_aio"}' +qemu-io: can't open: Cannot use relative extent paths with VMDK descriptor file 'json:{"image": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, "driver": "blkdebug", "inject-error.0.event": "read_aio"}' === Testing version 3 === image: TEST_DIR/iotest-version3.IMGFMT diff --git a/tests/qemu-iotests/083.out b/tests/qemu-iotests/083.out index 7419722cd7..eee6dd1379 100644 --- a/tests/qemu-iotests/083.out +++ b/tests/qemu-iotests/083.out @@ -1,43 +1,43 @@ QA output created by 083 === Check disconnect before neg1 === -can't open device nbd+tcp://127.0.0.1:PORT/foo +qemu-io: can't open device nbd+tcp://127.0.0.1:PORT/foo === Check disconnect after neg1 === -can't open device nbd+tcp://127.0.0.1:PORT/foo +qemu-io: can't open device nbd+tcp://127.0.0.1:PORT/foo === Check disconnect 8 neg1 === -can't open device nbd+tcp://127.0.0.1:PORT/foo +qemu-io: can't open device nbd+tcp://127.0.0.1:PORT/foo === Check disconnect 16 neg1 === -can't open device nbd+tcp://127.0.0.1:PORT/foo +qemu-io: can't open device nbd+tcp://127.0.0.1:PORT/foo === Check disconnect before export === -can't open device nbd+tcp://127.0.0.1:PORT/foo +qemu-io: can't open device nbd+tcp://127.0.0.1:PORT/foo === Check disconnect after export === -can't open device nbd+tcp://127.0.0.1:PORT/foo +qemu-io: can't open device nbd+tcp://127.0.0.1:PORT/foo === Check disconnect 4 export === -can't open device nbd+tcp://127.0.0.1:PORT/foo +qemu-io: can't open device nbd+tcp://127.0.0.1:PORT/foo === Check disconnect 12 export === -can't open device nbd+tcp://127.0.0.1:PORT/foo +qemu-io: can't open device nbd+tcp://127.0.0.1:PORT/foo === Check disconnect 16 export === -can't open device nbd+tcp://127.0.0.1:PORT/foo +qemu-io: can't open device nbd+tcp://127.0.0.1:PORT/foo === Check disconnect before neg2 === -can't open device nbd+tcp://127.0.0.1:PORT/foo +qemu-io: can't open device nbd+tcp://127.0.0.1:PORT/foo === Check disconnect after neg2 === @@ -45,11 +45,11 @@ read failed: Input/output error === Check disconnect 8 neg2 === -can't open device nbd+tcp://127.0.0.1:PORT/foo +qemu-io: can't open device nbd+tcp://127.0.0.1:PORT/foo === Check disconnect 10 neg2 === -can't open device nbd+tcp://127.0.0.1:PORT/foo +qemu-io: can't open device nbd+tcp://127.0.0.1:PORT/foo === Check disconnect before request === @@ -86,23 +86,23 @@ read 512/512 bytes at offset 0 === Check disconnect before neg-classic === -can't open device nbd+tcp://127.0.0.1:PORT/ +qemu-io: can't open device nbd+tcp://127.0.0.1:PORT/ === Check disconnect 8 neg-classic === -can't open device nbd+tcp://127.0.0.1:PORT/ +qemu-io: can't open device nbd+tcp://127.0.0.1:PORT/ === Check disconnect 16 neg-classic === -can't open device nbd+tcp://127.0.0.1:PORT/ +qemu-io: can't open device nbd+tcp://127.0.0.1:PORT/ === Check disconnect 24 neg-classic === -can't open device nbd+tcp://127.0.0.1:PORT/ +qemu-io: can't open device nbd+tcp://127.0.0.1:PORT/ === Check disconnect 28 neg-classic === -can't open device nbd+tcp://127.0.0.1:PORT/ +qemu-io: can't open device nbd+tcp://127.0.0.1:PORT/ === Check disconnect after neg-classic === @@ -110,43 +110,43 @@ read failed: Input/output error === Check disconnect before neg1 === -can't open device nbd+unix:///foo?socket=TEST_DIR/nbd.sock +qemu-io: can't open device nbd+unix:///foo?socket=TEST_DIR/nbd.sock === Check disconnect after neg1 === -can't open device nbd+unix:///foo?socket=TEST_DIR/nbd.sock +qemu-io: can't open device nbd+unix:///foo?socket=TEST_DIR/nbd.sock === Check disconnect 8 neg1 === -can't open device nbd+unix:///foo?socket=TEST_DIR/nbd.sock +qemu-io: can't open device nbd+unix:///foo?socket=TEST_DIR/nbd.sock === Check disconnect 16 neg1 === -can't open device nbd+unix:///foo?socket=TEST_DIR/nbd.sock +qemu-io: can't open device nbd+unix:///foo?socket=TEST_DIR/nbd.sock === Check disconnect before export === -can't open device nbd+unix:///foo?socket=TEST_DIR/nbd.sock +qemu-io: can't open device nbd+unix:///foo?socket=TEST_DIR/nbd.sock === Check disconnect after export === -can't open device nbd+unix:///foo?socket=TEST_DIR/nbd.sock +qemu-io: can't open device nbd+unix:///foo?socket=TEST_DIR/nbd.sock === Check disconnect 4 export === -can't open device nbd+unix:///foo?socket=TEST_DIR/nbd.sock +qemu-io: can't open device nbd+unix:///foo?socket=TEST_DIR/nbd.sock === Check disconnect 12 export === -can't open device nbd+unix:///foo?socket=TEST_DIR/nbd.sock +qemu-io: can't open device nbd+unix:///foo?socket=TEST_DIR/nbd.sock === Check disconnect 16 export === -can't open device nbd+unix:///foo?socket=TEST_DIR/nbd.sock +qemu-io: can't open device nbd+unix:///foo?socket=TEST_DIR/nbd.sock === Check disconnect before neg2 === -can't open device nbd+unix:///foo?socket=TEST_DIR/nbd.sock +qemu-io: can't open device nbd+unix:///foo?socket=TEST_DIR/nbd.sock === Check disconnect after neg2 === @@ -154,11 +154,11 @@ read failed: Input/output error === Check disconnect 8 neg2 === -can't open device nbd+unix:///foo?socket=TEST_DIR/nbd.sock +qemu-io: can't open device nbd+unix:///foo?socket=TEST_DIR/nbd.sock === Check disconnect 10 neg2 === -can't open device nbd+unix:///foo?socket=TEST_DIR/nbd.sock +qemu-io: can't open device nbd+unix:///foo?socket=TEST_DIR/nbd.sock === Check disconnect before request === @@ -195,23 +195,23 @@ read 512/512 bytes at offset 0 === Check disconnect before neg-classic === -can't open device nbd+unix:///?socket=TEST_DIR/nbd.sock +qemu-io: can't open device nbd+unix:///?socket=TEST_DIR/nbd.sock === Check disconnect 8 neg-classic === -can't open device nbd+unix:///?socket=TEST_DIR/nbd.sock +qemu-io: can't open device nbd+unix:///?socket=TEST_DIR/nbd.sock === Check disconnect 16 neg-classic === -can't open device nbd+unix:///?socket=TEST_DIR/nbd.sock +qemu-io: can't open device nbd+unix:///?socket=TEST_DIR/nbd.sock === Check disconnect 24 neg-classic === -can't open device nbd+unix:///?socket=TEST_DIR/nbd.sock +qemu-io: can't open device nbd+unix:///?socket=TEST_DIR/nbd.sock === Check disconnect 28 neg-classic === -can't open device nbd+unix:///?socket=TEST_DIR/nbd.sock +qemu-io: can't open device nbd+unix:///?socket=TEST_DIR/nbd.sock === Check disconnect after neg-classic === diff --git a/tests/qemu-iotests/092.out b/tests/qemu-iotests/092.out index 6eda321fc6..3e79914873 100644 --- a/tests/qemu-iotests/092.out +++ b/tests/qemu-iotests/092.out @@ -2,25 +2,25 @@ QA output created by 092 == Invalid cluster size == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 -can't open device TEST_DIR/t.qcow: Cluster size must be between 512 and 64k -can't open device TEST_DIR/t.qcow: Cluster size must be between 512 and 64k -can't open device TEST_DIR/t.qcow: Cluster size must be between 512 and 64k -can't open device TEST_DIR/t.qcow: Cluster size must be between 512 and 64k +qemu-io: can't open device TEST_DIR/t.qcow: Cluster size must be between 512 and 64k +qemu-io: can't open device TEST_DIR/t.qcow: Cluster size must be between 512 and 64k +qemu-io: can't open device TEST_DIR/t.qcow: Cluster size must be between 512 and 64k +qemu-io: can't open device TEST_DIR/t.qcow: Cluster size must be between 512 and 64k == Invalid L2 table size == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 -can't open device TEST_DIR/t.qcow: L2 table size must be between 512 and 64k -can't open device TEST_DIR/t.qcow: L2 table size must be between 512 and 64k -can't open device TEST_DIR/t.qcow: L2 table size must be between 512 and 64k -can't open device TEST_DIR/t.qcow: L2 table size must be between 512 and 64k +qemu-io: can't open device TEST_DIR/t.qcow: L2 table size must be between 512 and 64k +qemu-io: can't open device TEST_DIR/t.qcow: L2 table size must be between 512 and 64k +qemu-io: can't open device TEST_DIR/t.qcow: L2 table size must be between 512 and 64k +qemu-io: can't open device TEST_DIR/t.qcow: L2 table size must be between 512 and 64k == Invalid size == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 -can't open device TEST_DIR/t.qcow: Image too large -can't open device TEST_DIR/t.qcow: Image too large +qemu-io: can't open device TEST_DIR/t.qcow: Image too large +qemu-io: can't open device TEST_DIR/t.qcow: Image too large == Invalid backing file length == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 -can't open device TEST_DIR/t.qcow: Backing file name too long -can't open device TEST_DIR/t.qcow: Backing file name too long +qemu-io: can't open device TEST_DIR/t.qcow: Backing file name too long +qemu-io: can't open device TEST_DIR/t.qcow: Backing file name too long *** done diff --git a/tests/qemu-iotests/182 b/tests/qemu-iotests/182 index ff3d7e7ec1..38959bf276 100755 --- a/tests/qemu-iotests/182 +++ b/tests/qemu-iotests/182 @@ -31,6 +31,7 @@ _cleanup() { _cleanup_test_img rm -f "$TEST_IMG.overlay" + rm -f "$TEST_DIR/nbd.socket" } trap "_cleanup; exit \$status" 0 1 2 3 15 @@ -126,15 +127,26 @@ success_or_failure=y _send_qemu_cmd $QEMU_HANDLE \ 'return' \ 'error' -# Now we attach the image to a virtio-blk device. This device does -# require some permissions (at least WRITE and READ_CONSISTENT), so if +# Start an NBD server to which we can attach node1 +success_or_failure=y _send_qemu_cmd $QEMU_HANDLE \ + "{'execute': 'nbd-server-start', + 'arguments': { + 'addr': { + 'type': 'unix', + 'data': { + 'path': '$TEST_DIR/nbd.socket' + } } } }" \ + 'return' \ + 'error' + +# Now we attach the image to the NBD server. This server does require +# some permissions (at least WRITE and READ_CONSISTENT), so if # reopening node0 unshared any (which it should not have), this will # fail (but it should not). success_or_failure=y _send_qemu_cmd $QEMU_HANDLE \ - "{'execute': 'device_add', + "{'execute': 'nbd-server-add', 'arguments': { - 'driver': 'virtio-blk', - 'drive': 'node1' + 'device': 'node1' } }" \ 'return' \ 'error' diff --git a/tests/qemu-iotests/182.out b/tests/qemu-iotests/182.out index af501ca3f3..33d41eea91 100644 --- a/tests/qemu-iotests/182.out +++ b/tests/qemu-iotests/182.out @@ -14,4 +14,5 @@ Formatting 'TEST_DIR/t.qcow2.overlay', fmt=qcow2 size=197120 backing_file=TEST_D {"return": {}} {"return": {}} {"return": {}} +{"return": {}} *** done diff --git a/tests/qemu-iotests/221 b/tests/qemu-iotests/221 index 808cd9a289..25dd47bcfe 100755 --- a/tests/qemu-iotests/221 +++ b/tests/qemu-iotests/221 @@ -2,7 +2,7 @@ # # Test qemu-img vs. unaligned images # -# Copyright (C) 2018 Red Hat, Inc. +# Copyright (C) 2018-2019 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -41,16 +41,16 @@ echo echo "=== Check mapping of unaligned raw image ===" echo -_make_test_img 43009 # qemu-img create rounds size up +_make_test_img 65537 # qemu-img create rounds size up $QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map -truncate --size=43009 "$TEST_IMG" # so we resize it and check again +truncate --size=65537 "$TEST_IMG" # so we resize it and check again $QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map -$QEMU_IO -c 'w 43008 1' "$TEST_IMG" | _filter_qemu_io # writing also rounds up +$QEMU_IO -c 'w 65536 1' "$TEST_IMG" | _filter_qemu_io # writing also rounds up $QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map -truncate --size=43009 "$TEST_IMG" # so we resize it and check again +truncate --size=65537 "$TEST_IMG" # so we resize it and check again $QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map # success, all done diff --git a/tests/qemu-iotests/221.out b/tests/qemu-iotests/221.out index a9c0190aad..9f9dd52bb0 100644 --- a/tests/qemu-iotests/221.out +++ b/tests/qemu-iotests/221.out @@ -2,15 +2,15 @@ QA output created by 221 === Check mapping of unaligned raw image === -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=43009 -[{ "start": 0, "length": 43520, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] -[{ "start": 0, "length": 43520, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] -wrote 1/1 bytes at offset 43008 +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=65537 +[{ "start": 0, "length": 66048, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] +[{ "start": 0, "length": 66048, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] +wrote 1/1 bytes at offset 65536 1 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -[{ "start": 0, "length": 40960, "depth": 0, "zero": true, "data": false, "offset": OFFSET}, -{ "start": 40960, "length": 2049, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, -{ "start": 43009, "length": 511, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] -[{ "start": 0, "length": 40960, "depth": 0, "zero": true, "data": false, "offset": OFFSET}, -{ "start": 40960, "length": 2049, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, -{ "start": 43009, "length": 511, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] +[{ "start": 0, "length": 65536, "depth": 0, "zero": true, "data": false, "offset": OFFSET}, +{ "start": 65536, "length": 1, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, +{ "start": 65537, "length": 511, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] +[{ "start": 0, "length": 65536, "depth": 0, "zero": true, "data": false, "offset": OFFSET}, +{ "start": 65536, "length": 1, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, +{ "start": 65537, "length": 511, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] *** done diff --git a/tests/qemu-iotests/233 b/tests/qemu-iotests/233 index b8b6c8cc4c..41b4d46560 100755 --- a/tests/qemu-iotests/233 +++ b/tests/qemu-iotests/233 @@ -139,11 +139,13 @@ nbd_server_start_tcp_socket \ $QEMU_IMG info --image-opts \ --object tls-creds-x509,dir=${tls_dir}/client1,endpoint=client,id=tls0 \ - driver=nbd,host=$nbd_tcp_addr,port=$nbd_tcp_port,tls-creds=tls0 + driver=nbd,host=$nbd_tcp_addr,port=$nbd_tcp_port,tls-creds=tls0 \ + 2>&1 | sed "s/$nbd_tcp_port/PORT/g" $QEMU_IMG info --image-opts \ --object tls-creds-x509,dir=${tls_dir}/client3,endpoint=client,id=tls0 \ - driver=nbd,host=$nbd_tcp_addr,port=$nbd_tcp_port,tls-creds=tls0 + driver=nbd,host=$nbd_tcp_addr,port=$nbd_tcp_port,tls-creds=tls0 \ + 2>&1 | sed "s/$nbd_tcp_port/PORT/g" echo echo "== final server log ==" diff --git a/tests/qemu-iotests/233.out b/tests/qemu-iotests/233.out index 4edc2dd5cf..9b46284ab0 100644 --- a/tests/qemu-iotests/233.out +++ b/tests/qemu-iotests/233.out @@ -57,8 +57,8 @@ read 1048576/1048576 bytes at offset 1048576 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) == check TLS with authorization == -qemu-img: Could not open 'driver=nbd,host=127.0.0.1,port=10809,tls-creds=tls0': Failed to read option reply: Cannot read from TLS channel: Software caused connection abort -qemu-img: Could not open 'driver=nbd,host=127.0.0.1,port=10809,tls-creds=tls0': Failed to read option reply: Cannot read from TLS channel: Software caused connection abort +qemu-img: Could not open 'driver=nbd,host=127.0.0.1,port=PORT,tls-creds=tls0': Failed to read option reply: Cannot read from TLS channel: Software caused connection abort +qemu-img: Could not open 'driver=nbd,host=127.0.0.1,port=PORT,tls-creds=tls0': Failed to read option reply: Cannot read from TLS channel: Software caused connection abort == final server log == qemu-nbd: option negotiation failed: Verify failed: No certificate was found. diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 9705051690..ba6335e71a 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -830,6 +830,7 @@ static int unix_listen_saddr(UnixSocketAddress *saddr, int sock, fd; char *pathbuf = NULL; const char *path; + size_t pathlen; sock = qemu_socket(PF_UNIX, SOCK_STREAM, 0); if (sock < 0) { @@ -845,7 +846,8 @@ static int unix_listen_saddr(UnixSocketAddress *saddr, path = pathbuf = g_strdup_printf("%s/qemu-socket-XXXXXX", tmpdir); } - if (strlen(path) > sizeof(un.sun_path)) { + pathlen = strlen(path); + if (pathlen > sizeof(un.sun_path)) { error_setg(errp, "UNIX socket path '%s' is too long", path); error_append_hint(errp, "Path must be less than %zu bytes\n", sizeof(un.sun_path)); @@ -877,7 +879,7 @@ static int unix_listen_saddr(UnixSocketAddress *saddr, memset(&un, 0, sizeof(un)); un.sun_family = AF_UNIX; - strncpy(un.sun_path, path, sizeof(un.sun_path)); + memcpy(un.sun_path, path, pathlen); if (bind(sock, (struct sockaddr*) &un, sizeof(un)) < 0) { error_setg_errno(errp, errno, "Failed to bind socket to %s", path); @@ -901,6 +903,7 @@ static int unix_connect_saddr(UnixSocketAddress *saddr, Error **errp) { struct sockaddr_un un; int sock, rc; + size_t pathlen; if (saddr->path == NULL) { error_setg(errp, "unix connect: no path specified"); @@ -913,7 +916,8 @@ static int unix_connect_saddr(UnixSocketAddress *saddr, Error **errp) return -1; } - if (strlen(saddr->path) > sizeof(un.sun_path)) { + pathlen = strlen(saddr->path); + if (pathlen > sizeof(un.sun_path)) { error_setg(errp, "UNIX socket path '%s' is too long", saddr->path); error_append_hint(errp, "Path must be less than %zu bytes\n", sizeof(un.sun_path)); @@ -922,7 +926,7 @@ static int unix_connect_saddr(UnixSocketAddress *saddr, Error **errp) memset(&un, 0, sizeof(un)); un.sun_family = AF_UNIX; - strncpy(un.sun_path, saddr->path, sizeof(un.sun_path)); + memcpy(un.sun_path, saddr->path, pathlen); /* connect to peer */ do { |