Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/famz/tags/various-pull-request'…
Browse files Browse the repository at this point in the history
… into staging

# gpg: Signature made Fri 23 Sep 2016 05:58:28 BST
# gpg:                using RSA key 0xCA35624C6A9171C6
# gpg: Good signature from "Fam Zheng <famz@redhat.com>"
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 5003 7CB7 9706 0F76 F021  AD56 CA35 624C 6A91 71C6

* remotes/famz/tags/various-pull-request: (23 commits)
  docker: exec $CMD
  docker: Terminate instances at SIGTERM and SIGHUP
  docker: Support showing environment information
  docker: Print used options before doing configure
  docker: Flatten default target list in test-quick
  docker: Update fedora image to latest
  docker: Generate /packages.txt in ubuntu image
  docker: Generate /packages.txt in fedora image
  docker: Generate /packages.txt in centos6 image
  tests: Ignore test-uuid
  Add UUID files to MAINTAINERS
  tests: Add uuid tests
  uuid: Tighten uuid parse
  vl: Switch qemu_uuid to QemuUUID
  configure: Remove detection code for UUID
  tests: No longer dependent on CONFIG_UUID
  crypto: Switch to QEMU UUID API
  vpc: Use QEMU UUID API
  vdi: Use QEMU UUID API
  vhdx: Use QEMU UUID API
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

# Conflicts:
#	tests/Makefile.include
  • Loading branch information
pm215 committed Sep 23, 2016
2 parents 6de68ff + 9b77336 commit 4c89275
Show file tree
Hide file tree
Showing 36 changed files with 486 additions and 237 deletions.
7 changes: 7 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,13 @@ F: include/qemu/throttle.h
F: util/throttle.c
L: qemu-block@nongnu.org

UUID
M: Fam Zheng <famz@redhat.com>
S: Supported
F: util/uuid.c
F: include/qemu/uuid.h
F: tests/test-uuid.c

Usermode Emulation
------------------
Overall
Expand Down
19 changes: 0 additions & 19 deletions arch_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,25 +235,6 @@ void audio_init(void)
}
}

int qemu_uuid_parse(const char *str, uint8_t *uuid)
{
int ret;

if (strlen(str) != 36) {
return -1;
}

ret = sscanf(str, UUID_FMT, &uuid[0], &uuid[1], &uuid[2], &uuid[3],
&uuid[4], &uuid[5], &uuid[6], &uuid[7], &uuid[8], &uuid[9],
&uuid[10], &uuid[11], &uuid[12], &uuid[13], &uuid[14],
&uuid[15]);

if (ret != 16) {
return -1;
}
return 0;
}

void do_acpitable_option(const QemuOpts *opts)
{
#ifdef TARGET_I386
Expand Down
2 changes: 1 addition & 1 deletion block/Makefile.objs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ block-obj-y += raw_bsd.o qcow.o vdi.o vmdk.o cloop.o bochs.o vpc.o vvfat.o dmg.o
block-obj-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o qcow2-cache.o
block-obj-y += qed.o qed-gencb.o qed-l2-cache.o qed-table.o qed-cluster.o
block-obj-y += qed-check.o
block-obj-$(CONFIG_VHDX) += vhdx.o vhdx-endian.o vhdx-log.o
block-obj-y += vhdx.o vhdx-endian.o vhdx-log.o
block-obj-y += quorum.o
block-obj-y += parallels.o blkdebug.o blkverify.o blkreplay.o
block-obj-y += block-backend.o snapshot.o qapi.o
Expand Down
2 changes: 1 addition & 1 deletion block/iscsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include "block/block_int.h"
#include "block/scsi.h"
#include "qemu/iov.h"
#include "sysemu/sysemu.h"
#include "qemu/uuid.h"
#include "qmp-commands.h"
#include "qapi/qmp/qstring.h"
#include "crypto/secret.h"
Expand Down
73 changes: 17 additions & 56 deletions block/vdi.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,7 @@
#include "migration/migration.h"
#include "qemu/coroutine.h"
#include "qemu/cutils.h"

#if defined(CONFIG_UUID)
#include <uuid/uuid.h>
#else
/* TODO: move uuid emulation to some central place in QEMU. */
#include "sysemu/sysemu.h" /* UUID_FMT */
typedef unsigned char uuid_t[16];
#endif
#include "qemu/uuid.h"

/* Code configuration options. */

Expand Down Expand Up @@ -140,28 +133,6 @@ typedef unsigned char uuid_t[16];
#define VDI_DISK_SIZE_MAX ((uint64_t)VDI_BLOCKS_IN_IMAGE_MAX * \
(uint64_t)DEFAULT_CLUSTER_SIZE)

#if !defined(CONFIG_UUID)
static inline void uuid_generate(uuid_t out)
{
memset(out, 0, sizeof(uuid_t));
}

static inline int uuid_is_null(const uuid_t uu)
{
uuid_t null_uuid = { 0 };
return memcmp(uu, null_uuid, sizeof(uuid_t)) == 0;
}

# if defined(CONFIG_VDI_DEBUG)
static inline void uuid_unparse(const uuid_t uu, char *out)
{
snprintf(out, 37, UUID_FMT,
uu[0], uu[1], uu[2], uu[3], uu[4], uu[5], uu[6], uu[7],
uu[8], uu[9], uu[10], uu[11], uu[12], uu[13], uu[14], uu[15]);
}
# endif
#endif

typedef struct {
char text[0x40];
uint32_t signature;
Expand All @@ -182,10 +153,10 @@ typedef struct {
uint32_t block_extra; /* unused here */
uint32_t blocks_in_image;
uint32_t blocks_allocated;
uuid_t uuid_image;
uuid_t uuid_last_snap;
uuid_t uuid_link;
uuid_t uuid_parent;
QemuUUID uuid_image;
QemuUUID uuid_last_snap;
QemuUUID uuid_link;
QemuUUID uuid_parent;
uint64_t unused2[7];
} QEMU_PACKED VdiHeader;

Expand All @@ -206,16 +177,6 @@ typedef struct {
Error *migration_blocker;
} BDRVVdiState;

/* Change UUID from little endian (IPRT = VirtualBox format) to big endian
* format (network byte order, standard, see RFC 4122) and vice versa.
*/
static void uuid_convert(uuid_t uuid)
{
bswap32s((uint32_t *)&uuid[0]);
bswap16s((uint16_t *)&uuid[4]);
bswap16s((uint16_t *)&uuid[6]);
}

static void vdi_header_to_cpu(VdiHeader *header)
{
le32_to_cpus(&header->signature);
Expand All @@ -234,10 +195,10 @@ static void vdi_header_to_cpu(VdiHeader *header)
le32_to_cpus(&header->block_extra);
le32_to_cpus(&header->blocks_in_image);
le32_to_cpus(&header->blocks_allocated);
uuid_convert(header->uuid_image);
uuid_convert(header->uuid_last_snap);
uuid_convert(header->uuid_link);
uuid_convert(header->uuid_parent);
qemu_uuid_bswap(&header->uuid_image);
qemu_uuid_bswap(&header->uuid_last_snap);
qemu_uuid_bswap(&header->uuid_link);
qemu_uuid_bswap(&header->uuid_parent);
}

static void vdi_header_to_le(VdiHeader *header)
Expand All @@ -258,10 +219,10 @@ static void vdi_header_to_le(VdiHeader *header)
cpu_to_le32s(&header->block_extra);
cpu_to_le32s(&header->blocks_in_image);
cpu_to_le32s(&header->blocks_allocated);
uuid_convert(header->uuid_image);
uuid_convert(header->uuid_last_snap);
uuid_convert(header->uuid_link);
uuid_convert(header->uuid_parent);
qemu_uuid_bswap(&header->uuid_image);
qemu_uuid_bswap(&header->uuid_last_snap);
qemu_uuid_bswap(&header->uuid_link);
qemu_uuid_bswap(&header->uuid_parent);
}

#if defined(CONFIG_VDI_DEBUG)
Expand Down Expand Up @@ -469,11 +430,11 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
(uint64_t)header.blocks_in_image * header.block_size);
ret = -ENOTSUP;
goto fail;
} else if (!uuid_is_null(header.uuid_link)) {
} else if (!qemu_uuid_is_null(&header.uuid_link)) {
error_setg(errp, "unsupported VDI image (non-NULL link UUID)");
ret = -ENOTSUP;
goto fail;
} else if (!uuid_is_null(header.uuid_parent)) {
} else if (!qemu_uuid_is_null(&header.uuid_parent)) {
error_setg(errp, "unsupported VDI image (non-NULL parent UUID)");
ret = -ENOTSUP;
goto fail;
Expand Down Expand Up @@ -821,8 +782,8 @@ static int vdi_create(const char *filename, QemuOpts *opts, Error **errp)
if (image_type == VDI_TYPE_STATIC) {
header.blocks_allocated = blocks;
}
uuid_generate(header.uuid_image);
uuid_generate(header.uuid_last_snap);
qemu_uuid_generate(&header.uuid_image);
qemu_uuid_generate(&header.uuid_last_snap);
/* There is no need to set header.uuid_link or header.uuid_parent here. */
#if defined(CONFIG_VDI_DEBUG)
vdi_header_print(&header);
Expand Down
3 changes: 0 additions & 3 deletions block/vhdx-endian.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
#include "qemu/bswap.h"
#include "block/vhdx.h"

#include <uuid/uuid.h>


/*
* All the VHDX formats on disk are little endian - the following
* are helper import/export functions to correctly convert
Expand Down
9 changes: 4 additions & 5 deletions block/vhdx.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
#include "qemu/bswap.h"
#include "block/vhdx.h"
#include "migration/migration.h"

#include <uuid/uuid.h>
#include "qemu/uuid.h"

/* Options for VHDX creation */

Expand Down Expand Up @@ -213,11 +212,11 @@ bool vhdx_checksum_is_valid(uint8_t *buf, size_t size, int crc_offset)
*/
void vhdx_guid_generate(MSGUID *guid)
{
uuid_t uuid;
QemuUUID uuid;
assert(guid != NULL);

uuid_generate(uuid);
memcpy(guid, uuid, sizeof(MSGUID));
qemu_uuid_generate(&uuid);
memcpy(guid, &uuid, sizeof(MSGUID));
}

/* Check for region overlaps inside the VHDX image */
Expand Down
10 changes: 3 additions & 7 deletions block/vpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@
#include "qemu/module.h"
#include "migration/migration.h"
#include "qemu/bswap.h"
#if defined(CONFIG_UUID)
#include <uuid/uuid.h>
#endif
#include "qemu/uuid.h"

/**************************************************************/

Expand Down Expand Up @@ -89,7 +87,7 @@ typedef struct vhd_footer {
uint32_t checksum;

/* UUID used to identify a parent hard disk (backing file) */
uint8_t uuid[16];
QemuUUID uuid;

uint8_t in_saved_state;
} QEMU_PACKED VHDFooter;
Expand Down Expand Up @@ -980,9 +978,7 @@ static int vpc_create(const char *filename, QemuOpts *opts, Error **errp)

footer->type = cpu_to_be32(disk_type);

#if defined(CONFIG_UUID)
uuid_generate(footer->uuid);
#endif
qemu_uuid_generate(&footer->uuid);

footer->checksum = cpu_to_be32(vpc_checksum(buf, HEADER_SIZE));

Expand Down
Loading

0 comments on commit 4c89275

Please sign in to comment.