~ubuntu-branches/ubuntu/trusty/qemu/trusty

« back to all changes in this revision

Viewing changes to block/sheepdog.c

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2013-10-22 22:47:07 UTC
  • mfrom: (1.8.3) (10.1.42 sid)
  • Revision ID: package-import@ubuntu.com-20131022224707-1lya34fw3k3f24tv
Tags: 1.6.0+dfsg-2ubuntu1
* Merge 1.6.0~rc0+dfsg-2exp from debian experimental.  Remaining changes:
  - debian/control
    * update maintainer
    * remove libiscsi, usb-redir, vde, vnc-jpeg, and libssh2-1-dev
      from build-deps
    * enable rbd
    * add qemu-system and qemu-common B/R to qemu-keymaps
    * add D:udev, R:qemu, R:qemu-common and B:qemu-common to
      qemu-system-common
    * qemu-system-arm, qemu-system-ppc, qemu-system-sparc:
      - add qemu-kvm to Provides
      - add qemu-common, qemu-kvm, kvm to B/R
      - remove openbios-sparc from qemu-system-sparc D
      - drop openbios-ppc and openhackware Depends to Suggests (for now)
    * qemu-system-x86:
      - add qemu-common to Breaks/Replaces.
      - add cpu-checker to Recommends.
    * qemu-user: add B/R:qemu-kvm
    * qemu-kvm:
      - add armhf armel powerpc sparc to Architecture
      - C/R/P: qemu-kvm-spice
    * add qemu-common package
    * drop qemu-slof which is not packaged in ubuntu
  - add qemu-system-common.links for tap ifup/down scripts and OVMF link.
  - qemu-system-x86.links:
    * remove pxe rom links which are in kvm-ipxe
    * add symlink for kvm.1 manpage
  - debian/rules
    * add kvm-spice symlink to qemu-kvm
    * call dh_installmodules for qemu-system-x86
    * update dh_installinit to install upstart script
    * run dh_installman (Closes: #709241) (cherrypicked from 1.5.0+dfsg-2)
  - Add qemu-utils.links for kvm-* symlinks.
  - Add qemu-system-x86.qemu-kvm.upstart and .default
  - Add qemu-system-x86.modprobe to set nesting=1
  - Add qemu-system-common.preinst to add kvm group
  - qemu-system-common.postinst: remove bad group acl if there, then have
    udev relabel /dev/kvm.
  - New linaro patches from qemu-linaro rebasing branch
  - Dropped patches:
    * xen-simplify-xen_enabled.patch
    * sparc-linux-user-fix-missing-symbols-in-.rel-.rela.plt-sections.patch
    * main_loop-do-not-set-nonblocking-if-xen_enabled.patch
    * xen_machine_pv-do-not-create-a-dummy-CPU-in-machine-.patch
    * virtio-rng-fix-crash
  - Kept patches:
    * expose_vms_qemu64cpu.patch - updated
    * linaro arm patches from qemu-linaro rebasing branch
  - New patches:
    * fix-pci-add: change CONFIG variable in ifdef to make sure that
      pci_add is defined.
* Add linaro patches
* Add experimental mach-virt patches for arm virtualization.
* qemu-system-common.install: add debian/tmp/usr/lib to install the
  qemu-bridge-helper

Show diffs side-by-side

added added

removed removed

Lines of Context:
242
242
    return !!inode->snap_ctime;
243
243
}
244
244
 
245
 
#undef dprintf
 
245
#undef DPRINTF
246
246
#ifdef DEBUG_SDOG
247
 
#define dprintf(fmt, args...)                                       \
 
247
#define DPRINTF(fmt, args...)                                       \
248
248
    do {                                                            \
249
249
        fprintf(stdout, "%s %d: " fmt, __func__, __LINE__, ##args); \
250
250
    } while (0)
251
251
#else
252
 
#define dprintf(fmt, args...)
 
252
#define DPRINTF(fmt, args...)
253
253
#endif
254
254
 
255
255
typedef struct SheepdogAIOCB SheepdogAIOCB;
729
729
        break;
730
730
    case AIOCB_FLUSH_CACHE:
731
731
        if (rsp.result == SD_RES_INVALID_PARMS) {
732
 
            dprintf("disable cache since the server doesn't support it\n");
 
732
            DPRINTF("disable cache since the server doesn't support it\n");
733
733
            s->cache_flags = SD_FLAG_CMD_DIRECT;
734
734
            rsp.result = SD_RES_SUCCESS;
735
735
        }
1229
1229
         * the same object */
1230
1230
        QLIST_FOREACH(areq, &s->inflight_aio_head, aio_siblings) {
1231
1231
            if (areq != aio_req && areq->oid == aio_req->oid) {
1232
 
                dprintf("simultaneous CoW to %" PRIx64 "\n", aio_req->oid);
 
1232
                DPRINTF("simultaneous CoW to %" PRIx64 "\n", aio_req->oid);
1233
1233
                QLIST_REMOVE(aio_req, aio_siblings);
1234
1234
                QLIST_INSERT_HEAD(&s->pending_aio_head, aio_req, aio_siblings);
1235
1235
                return SD_RES_SUCCESS;
1319
1319
    s->discard_supported = true;
1320
1320
 
1321
1321
    if (snapid || tag[0] != '\0') {
1322
 
        dprintf("%" PRIx32 " snapshot inode was open.\n", vid);
 
1322
        DPRINTF("%" PRIx32 " snapshot inode was open.\n", vid);
1323
1323
        s->is_snapshot = true;
1324
1324
    }
1325
1325
 
1510
1510
        BlockDriver *drv;
1511
1511
 
1512
1512
        /* Currently, only Sheepdog backing image is supported. */
1513
 
        drv = bdrv_find_protocol(backing_file);
 
1513
        drv = bdrv_find_protocol(backing_file, true);
1514
1514
        if (!drv || strcmp(drv->protocol_name, "sheepdog") != 0) {
1515
1515
            error_report("backing_file must be a sheepdog image");
1516
1516
            ret = -EINVAL;
1554
1554
    unsigned int wlen, rlen = 0;
1555
1555
    int fd, ret;
1556
1556
 
1557
 
    dprintf("%s\n", s->name);
 
1557
    DPRINTF("%s\n", s->name);
1558
1558
 
1559
1559
    fd = connect_to_sdog(s);
1560
1560
    if (fd < 0) {
1714
1714
    char *buf;
1715
1715
    bool deleted;
1716
1716
 
1717
 
    dprintf("%" PRIx32 " is snapshot.\n", s->inode.vdi_id);
 
1717
    DPRINTF("%" PRIx32 " is snapshot.\n", s->inode.vdi_id);
1718
1718
 
1719
1719
    buf = g_malloc(SD_INODE_SIZE);
1720
1720
 
1730
1730
        goto out;
1731
1731
    }
1732
1732
 
1733
 
    dprintf("%" PRIx32 " is created.\n", vid);
 
1733
    DPRINTF("%" PRIx32 " is created.\n", vid);
1734
1734
 
1735
1735
    fd = connect_to_sdog(s);
1736
1736
    if (fd < 0) {
1751
1751
 
1752
1752
    s->is_snapshot = false;
1753
1753
    ret = 0;
1754
 
    dprintf("%" PRIx32 " was newly created.\n", s->inode.vdi_id);
 
1754
    DPRINTF("%" PRIx32 " was newly created.\n", s->inode.vdi_id);
1755
1755
 
1756
1756
out:
1757
1757
    g_free(buf);
1841
1841
        }
1842
1842
 
1843
1843
        if (create) {
1844
 
            dprintf("update ino (%" PRIu32 ") %" PRIu64 " %" PRIu64 " %ld\n",
 
1844
            DPRINTF("update ino (%" PRIu32 ") %" PRIu64 " %" PRIu64 " %ld\n",
1845
1845
                    inode->vdi_id, oid,
1846
1846
                    vid_to_data_oid(inode->data_vdi_id[idx], idx), idx);
1847
1847
            oid = vid_to_data_oid(inode->vdi_id, idx);
1848
 
            dprintf("new oid %" PRIx64 "\n", oid);
 
1848
            DPRINTF("new oid %" PRIx64 "\n", oid);
1849
1849
        }
1850
1850
 
1851
1851
        aio_req = alloc_aio_req(s, acb, oid, len, offset, flags, old_oid, done);
1978
1978
    SheepdogInode *inode;
1979
1979
    unsigned int datalen;
1980
1980
 
1981
 
    dprintf("sn_info: name %s id_str %s s: name %s vm_state_size %" PRId64 " "
 
1981
    DPRINTF("sn_info: name %s id_str %s s: name %s vm_state_size %" PRId64 " "
1982
1982
            "is_snapshot %d\n", sn_info->name, sn_info->id_str,
1983
1983
            s->name, sn_info->vm_state_size, s->is_snapshot);
1984
1984
 
1989
1989
        return -EINVAL;
1990
1990
    }
1991
1991
 
1992
 
    dprintf("%s %s\n", sn_info->name, sn_info->id_str);
 
1992
    DPRINTF("%s %s\n", sn_info->name, sn_info->id_str);
1993
1993
 
1994
1994
    s->inode.vm_state_size = sn_info->vm_state_size;
1995
1995
    s->inode.vm_clock_nsec = sn_info->vm_clock_nsec;
2033
2033
    }
2034
2034
 
2035
2035
    memcpy(&s->inode, inode, datalen);
2036
 
    dprintf("s->inode: name %s snap_id %x oid %x\n",
 
2036
    DPRINTF("s->inode: name %s snap_id %x oid %x\n",
2037
2037
            s->inode.name, s->inode.snap_id, s->inode.vdi_id);
2038
2038
 
2039
2039
cleanup:
2063
2063
    if (snapid) {
2064
2064
        tag[0] = 0;
2065
2065
    } else {
2066
 
        pstrcpy(tag, sizeof(tag), s->name);
 
2066
        pstrcpy(tag, sizeof(tag), snapshot_id);
2067
2067
    }
2068
2068
 
2069
2069
    ret = reload_inode(s, snapid, tag);
2071
2071
        goto out;
2072
2072
    }
2073
2073
 
2074
 
    if (!s->inode.vm_state_size) {
2075
 
        error_report("Invalid snapshot");
2076
 
        ret = -ENOENT;
 
2074
    ret = sd_create_branch(s);
 
2075
    if (ret) {
2077
2076
        goto out;
2078
2077
    }
2079
2078
 
2080
 
    s->is_snapshot = true;
2081
 
 
2082
2079
    g_free(old_s);
2083
2080
 
2084
2081
    return 0;
2196
2193
    int fd, ret = 0, remaining = size;
2197
2194
    unsigned int data_len;
2198
2195
    uint64_t vmstate_oid;
 
2196
    uint64_t offset;
2199
2197
    uint32_t vdi_index;
2200
 
    uint64_t offset;
 
2198
    uint32_t vdi_id = load ? s->inode.parent_vdi_id : s->inode.vdi_id;
2201
2199
 
2202
2200
    fd = connect_to_sdog(s);
2203
2201
    if (fd < 0) {
2210
2208
 
2211
2209
        data_len = MIN(remaining, SD_DATA_OBJ_SIZE - offset);
2212
2210
 
2213
 
        vmstate_oid = vid_to_vmstate_oid(s->inode.vdi_id, vdi_index);
 
2211
        vmstate_oid = vid_to_vmstate_oid(vdi_id, vdi_index);
2214
2212
 
2215
2213
        create = (offset == 0);
2216
2214
        if (load) {
2349
2347
    .bdrv_file_open = sd_open,
2350
2348
    .bdrv_close     = sd_close,
2351
2349
    .bdrv_create    = sd_create,
 
2350
    .bdrv_has_zero_init = bdrv_has_zero_init_1,
2352
2351
    .bdrv_getlength = sd_getlength,
2353
2352
    .bdrv_truncate  = sd_truncate,
2354
2353
 
2376
2375
    .bdrv_file_open = sd_open,
2377
2376
    .bdrv_close     = sd_close,
2378
2377
    .bdrv_create    = sd_create,
 
2378
    .bdrv_has_zero_init = bdrv_has_zero_init_1,
2379
2379
    .bdrv_getlength = sd_getlength,
2380
2380
    .bdrv_truncate  = sd_truncate,
2381
2381
 
2403
2403
    .bdrv_file_open = sd_open,
2404
2404
    .bdrv_close     = sd_close,
2405
2405
    .bdrv_create    = sd_create,
 
2406
    .bdrv_has_zero_init = bdrv_has_zero_init_1,
2406
2407
    .bdrv_getlength = sd_getlength,
2407
2408
    .bdrv_truncate  = sd_truncate,
2408
2409