Commit 128dc2d1 authored by Anthony Liguori's avatar Anthony Liguori
Browse files

Merge remote-tracking branch 'kwolf/for-anthony' into staging



# By Liu Yuan (2) and others
# Via Kevin Wolf
* kwolf/for-anthony:
  vmdk: Allow reading variable size descriptor files
  NVMe: Initial commit for new storage interface
  curl: Don't set curl options on the handle just before it's going to be deleted.
  vmdk: byteswap VMDK4Header.desc_offset field
  block/curl.c: Refuse to open the handle for writes.
  sheepdog: support 'qemu-img snapshot -a'
  sheepdog: fix snapshot tag initialization

Message-id: 1371486710-17793-1-git-send-email-kwolf@redhat.com
Signed-off-by: default avatarAnthony Liguori <aliguori@us.ibm.com>
parents 5d71bbc5 0bed087d
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -609,6 +609,11 @@ S: Supported
F: hw/char/virtio-serial-bus.c
F: hw/char/virtio-console.c

nvme
M: Keith Busch <keith.busch@intel.com>
S: Supported
F: hw/block/nvme*

Xilinx EDK
M: Peter Crosthwaite <peter.crosthwaite@petalogix.com>
M: Edgar E. Iglesias <edgar.iglesias@gmail.com>
+6 −2
Original line number Diff line number Diff line
@@ -406,6 +406,12 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags)

    static int inited = 0;

    if (flags & BDRV_O_RDWR) {
        qerror_report(ERROR_CLASS_GENERIC_ERROR,
                      "curl block device does not support writes");
        return -EROFS;
    }

    opts = qemu_opts_create_nofail(&runtime_opts);
    qemu_opts_absorb_qdict(opts, options, &local_err);
    if (error_is_set(&local_err)) {
@@ -446,8 +452,6 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags)
    if (curl_easy_perform(state->curl))
        goto out;
    curl_easy_getinfo(state->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &d);
    curl_easy_setopt(state->curl, CURLOPT_WRITEFUNCTION, (void *)curl_read_cb);
    curl_easy_setopt(state->curl, CURLOPT_NOBODY, 0);
    if (d)
        s->len = (size_t)d;
    else if(!s->len)
+6 −8
Original line number Diff line number Diff line
@@ -2063,7 +2063,7 @@ static int sd_snapshot_goto(BlockDriverState *bs, const char *snapshot_id)
    if (snapid) {
        tag[0] = 0;
    } else {
        pstrcpy(tag, sizeof(tag), s->name);
        pstrcpy(tag, sizeof(tag), snapshot_id);
    }

    ret = reload_inode(s, snapid, tag);
@@ -2071,14 +2071,11 @@ static int sd_snapshot_goto(BlockDriverState *bs, const char *snapshot_id)
        goto out;
    }

    if (!s->inode.vm_state_size) {
        error_report("Invalid snapshot");
        ret = -ENOENT;
    ret = sd_create_branch(s);
    if (ret) {
        goto out;
    }

    s->is_snapshot = true;

    g_free(old_s);

    return 0;
@@ -2196,8 +2193,9 @@ static int do_load_save_vmstate(BDRVSheepdogState *s, uint8_t *data,
    int fd, ret = 0, remaining = size;
    unsigned int data_len;
    uint64_t vmstate_oid;
    uint32_t vdi_index;
    uint64_t offset;
    uint32_t vdi_index;
    uint32_t vdi_id = load ? s->inode.parent_vdi_id : s->inode.vdi_id;

    fd = connect_to_sdog(s);
    if (fd < 0) {
@@ -2210,7 +2208,7 @@ static int do_load_save_vmstate(BDRVSheepdogState *s, uint8_t *data,

        data_len = MIN(remaining, SD_DATA_OBJ_SIZE - offset);

        vmstate_oid = vid_to_vmstate_oid(s->inode.vdi_id, vdi_index);
        vmstate_oid = vid_to_vmstate_oid(vdi_id, vdi_index);

        create = (offset == 0);
        if (load) {
+25 −9
Original line number Diff line number Diff line
@@ -507,8 +507,11 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,
    if (ret < 0) {
        return ret;
    }
    if (header.capacity == 0 && header.desc_offset) {
        return vmdk_open_desc_file(bs, flags, header.desc_offset << 9);
    if (header.capacity == 0) {
        int64_t desc_offset = le64_to_cpu(header.desc_offset);
        if (desc_offset) {
            return vmdk_open_desc_file(bs, flags, desc_offset << 9);
        }
    }

    if (le64_to_cpu(header.gd_offset) == VMDK4_GD_AT_END) {
@@ -719,27 +722,40 @@ static int vmdk_open_desc_file(BlockDriverState *bs, int flags,
                               int64_t desc_offset)
{
    int ret;
    char buf[2048];
    char *buf = NULL;
    char ct[128];
    BDRVVmdkState *s = bs->opaque;
    int64_t size;

    size = bdrv_getlength(bs->file);
    if (size < 0) {
        return -EINVAL;
    }

    ret = bdrv_pread(bs->file, desc_offset, buf, sizeof(buf));
    size = MIN(size, 1 << 20);  /* avoid unbounded allocation */
    buf = g_malloc0(size + 1);

    ret = bdrv_pread(bs->file, desc_offset, buf, size);
    if (ret < 0) {
        return ret;
        goto exit;
    }
    buf[2047] = '\0';
    if (vmdk_parse_description(buf, "createType", ct, sizeof(ct))) {
        return -EMEDIUMTYPE;
        ret = -EMEDIUMTYPE;
        goto exit;
    }
    if (strcmp(ct, "monolithicFlat") &&
        strcmp(ct, "twoGbMaxExtentSparse") &&
        strcmp(ct, "twoGbMaxExtentFlat")) {
        fprintf(stderr,
                "VMDK: Not supported image type \"%s\""".\n", ct);
        return -ENOTSUP;
        ret = -ENOTSUP;
        goto exit;
    }
    s->desc_offset = 0;
    return vmdk_parse_extents(buf, bs, bs->file->filename);
    ret = vmdk_parse_extents(buf, bs, bs->file->filename);
exit:
    g_free(buf);
    return ret;
}

static int vmdk_open(BlockDriverState *bs, QDict *options, int flags)
+1 −0
Original line number Diff line number Diff line
@@ -29,3 +29,4 @@ CONFIG_SERIAL_PCI=y
CONFIG_IPACK=y
CONFIG_WDT_IB6300ESB=y
CONFIG_PCI_TESTDEV=y
CONFIG_NVME_PCI=y
Loading