Commit 507ef2f9 authored by Peter Maydell's avatar Peter Maydell
Browse files

Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging



# gpg: Signature made Sat 04 Oct 2014 21:24:46 BST using RSA key ID 81AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>"
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>"

* remotes/stefanha/tags/block-pull-request: (23 commits)
  blockdev-test: Test device_del after drive_del
  blockdev-test: Factor out some common code into helpers
  blockdev-test: Simplify by using g_assert_cmpstr()
  blockdev-test: Clean up bogus drive_add argument
  blockdev-test: Use single rather than double quotes in QMP
  drive_del-test: Merge of qdev-monitor-test, blockdev-test
  iotests: qemu-img info output for corrupt image
  qapi: Add corrupt field to ImageInfoSpecificQCow2
  iotests: Use _img_info
  util: Emancipate id_wellformed() from QemuOpts
  q35/ahci: Pick up -cdrom and -hda options
  qtest/bios-tables: Correct Q35 command line
  ide: Update ide_drive_get to be HBA agnostic
  pc/vl: Add units-per-default-bus property
  blockdev: Allow overriding if_max_dev property
  blockdev: Orphaned drive search
  qemu-iotests: Fix supported cache modes for 052
  make check-block: Use default cache modes
  Modify qemu_opt_rename to realize renaming all items in opts
  vmdk: Fix integer overflow in offset calculation
  ...

Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parents b00a0ddb 767c86d3
Loading
Loading
Loading
Loading
+2 −7
Original line number Diff line number Diff line
@@ -335,18 +335,13 @@ void bdrv_register(BlockDriver *bdrv)
    QLIST_INSERT_HEAD(&bdrv_drivers, bdrv, list);
}

static bool bdrv_is_valid_name(const char *name)
{
    return qemu_opts_id_wellformed(name);
}

/* create a new block device (by default it is empty) */
BlockDriverState *bdrv_new(const char *device_name, Error **errp)
{
    BlockDriverState *bs;
    int i;

    if (*device_name && !bdrv_is_valid_name(device_name)) {
    if (*device_name && !id_wellformed(device_name)) {
        error_setg(errp, "Invalid device name");
        return NULL;
    }
@@ -874,7 +869,7 @@ static void bdrv_assign_node_name(BlockDriverState *bs,
    }

    /* Check for empty string or invalid characters */
    if (!bdrv_is_valid_name(node_name)) {
    if (!id_wellformed(node_name)) {
        error_setg(errp, "Invalid node name");
        return;
    }
+3 −0
Original line number Diff line number Diff line
@@ -2282,6 +2282,9 @@ static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs)
            .lazy_refcounts     = s->compatible_features &
                                  QCOW2_COMPAT_LAZY_REFCOUNTS,
            .has_lazy_refcounts = true,
            .corrupt            = s->incompatible_features &
                                  QCOW2_INCOMPAT_CORRUPT,
            .has_corrupt        = true,
        };
    }

+10 −0
Original line number Diff line number Diff line
@@ -517,6 +517,11 @@ static int connect_to_ssh(BDRVSSHState *s, QDict *options,
    const char *host, *user, *path, *host_key_check;
    int port;

    if (!qdict_haskey(options, "host")) {
        ret = -EINVAL;
        error_setg(errp, "No hostname was specified");
        goto err;
    }
    host = qdict_get_str(options, "host");

    if (qdict_haskey(options, "port")) {
@@ -525,6 +530,11 @@ static int connect_to_ssh(BDRVSSHState *s, QDict *options,
        port = 22;
    }

    if (!qdict_haskey(options, "path")) {
        ret = -EINVAL;
        error_setg(errp, "No path was specified");
        goto err;
    }
    path = qdict_get_str(options, "path");

    if (qdict_haskey(options, "user")) {
+1 −1
Original line number Diff line number Diff line
@@ -1113,7 +1113,7 @@ static int get_cluster_offset(BlockDriverState *bs,
    uint32_t min_count, *l2_table;
    bool zeroed = false;
    int64_t ret;
    int32_t cluster_sector;
    int64_t cluster_sector;

    if (m_data) {
        m_data->valid = 0;
+68 −4
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ static const char *const if_name[IF_COUNT] = {
    [IF_XEN] = "xen",
};

static const int if_max_devs[IF_COUNT] = {
static int if_max_devs[IF_COUNT] = {
    /*
     * Do not change these numbers!  They govern how drive option
     * index maps to unit and bus.  That mapping is ABI.
@@ -79,6 +79,30 @@ static const int if_max_devs[IF_COUNT] = {
    [IF_SCSI] = 7,
};

/**
 * Boards may call this to offer board-by-board overrides
 * of the default, global values.
 */
void override_max_devs(BlockInterfaceType type, int max_devs)
{
    DriveInfo *dinfo;

    if (max_devs <= 0) {
        return;
    }

    QTAILQ_FOREACH(dinfo, &drives, next) {
        if (dinfo->type == type) {
            fprintf(stderr, "Cannot override units-per-bus property of"
                    " the %s interface, because a drive of that type has"
                    " already been added.\n", if_name[type]);
            g_assert_not_reached();
        }
    }

    if_max_devs[type] = max_devs;
}

/*
 * We automatically delete the drive when a device using it gets
 * unplugged.  Questionable feature, but we can't just drop it.
@@ -111,6 +135,23 @@ void blockdev_auto_del(BlockDriverState *bs)
    }
}

/**
 * Returns the current mapping of how many units per bus
 * a particular interface can support.
 *
 *  A positive integer indicates n units per bus.
 *  0 implies the mapping has not been established.
 * -1 indicates an invalid BlockInterfaceType was given.
 */
int drive_get_max_devs(BlockInterfaceType type)
{
    if (type >= IF_IDE && type < IF_COUNT) {
        return if_max_devs[type];
    }

    return -1;
}

static int drive_index_to_bus_id(BlockInterfaceType type, int index)
{
    int max_devs = if_max_devs[type];
@@ -166,6 +207,27 @@ DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit)
    return NULL;
}

bool drive_check_orphaned(void)
{
    DriveInfo *dinfo;
    bool rs = false;

    QTAILQ_FOREACH(dinfo, &drives, next) {
        /* If dinfo->bdrv->dev is NULL, it has no device attached. */
        /* Unless this is a default drive, this may be an oversight. */
        if (!dinfo->bdrv->dev && !dinfo->is_default &&
            dinfo->type != IF_NONE) {
            fprintf(stderr, "Warning: Orphaned drive without device: "
                    "id=%s,file=%s,if=%s,bus=%d,unit=%d\n",
                    dinfo->id, dinfo->bdrv->filename, if_name[dinfo->type],
                    dinfo->bus, dinfo->unit);
            rs = true;
        }
    }

    return rs;
}

DriveInfo *drive_get_by_index(BlockInterfaceType type, int index)
{
    return drive_get(type,
@@ -224,9 +286,7 @@ void drive_info_del(DriveInfo *dinfo)
    if (!dinfo) {
        return;
    }
    if (dinfo->opts) {
    qemu_opts_del(dinfo->opts);
    }
    g_free(dinfo->id);
    QTAILQ_REMOVE(&drives, dinfo, next);
    g_free(dinfo->serial);
@@ -550,6 +610,10 @@ static void qemu_opt_rename(QemuOpts *opts, const char *from, const char *to,
                       "same time", to, from);
            return;
        }
    }

    /* rename all items in opts */
    while ((value = qemu_opt_get(opts, from))) {
        qemu_opt_set(opts, to, value);
        qemu_opt_unset(opts, from);
    }
Loading