From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51481) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vq7m0-0006YV-6F for qemu-devel@nongnu.org; Mon, 09 Dec 2013 15:49:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vq7lu-0003tz-LV for qemu-devel@nongnu.org; Mon, 09 Dec 2013 15:49:48 -0500 Received: from mail-ee0-x233.google.com ([2a00:1450:4013:c00::233]:46050) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vq7lu-0003tq-AJ for qemu-devel@nongnu.org; Mon, 09 Dec 2013 15:49:42 -0500 Received: by mail-ee0-f51.google.com with SMTP id b15so1819194eek.10 for ; Mon, 09 Dec 2013 12:49:41 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Mon, 9 Dec 2013 21:48:24 +0100 Message-Id: <1386622112-27257-23-git-send-email-pbonzini@redhat.com> In-Reply-To: <1386622112-27257-1-git-send-email-pbonzini@redhat.com> References: <1386622112-27257-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PULL 22/30] virtio-9p: Convert to QOM realize List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: cornelia.huck@de.ibm.com, afaerber@suse.de, mst@redhat.com From: Andreas Färber Signed-off-by: Andreas Färber Signed-off-by: Paolo Bonzini --- hw/9pfs/virtio-9p-device.c | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c index ea21655..15a4983 100644 --- a/hw/9pfs/virtio-9p-device.c +++ b/hw/9pfs/virtio-9p-device.c @@ -41,9 +41,10 @@ static void virtio_9p_get_config(VirtIODevice *vdev, uint8_t *config) g_free(cfg); } -static int virtio_9p_device_init(VirtIODevice *vdev) +static void virtio_9p_device_realize(DeviceState *dev, Error **errp) { - V9fsState *s = VIRTIO_9P(vdev); + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + V9fsState *s = VIRTIO_9P(dev); int i, len; struct stat stat; FsDriverEntry *fse; @@ -67,16 +68,16 @@ static int virtio_9p_device_init(VirtIODevice *vdev) if (!fse) { /* We don't have a fsdev identified by fsdev_id */ - fprintf(stderr, "Virtio-9p device couldn't find fsdev with the " - "id = %s\n", - s->fsconf.fsdev_id ? s->fsconf.fsdev_id : "NULL"); + error_setg(errp, "Virtio-9p device couldn't find fsdev with the " + "id = %s", + s->fsconf.fsdev_id ? s->fsconf.fsdev_id : "NULL"); goto out; } if (!s->fsconf.tag) { /* we haven't specified a mount_tag */ - fprintf(stderr, "fsdev with id %s needs mount_tag arguments\n", - s->fsconf.fsdev_id); + error_setg(errp, "fsdev with id %s needs mount_tag arguments", + s->fsconf.fsdev_id); goto out; } @@ -85,8 +86,8 @@ static int virtio_9p_device_init(VirtIODevice *vdev) s->ctx.exops.get_st_gen = NULL; len = strlen(s->fsconf.tag); if (len > MAX_TAG_LEN - 1) { - fprintf(stderr, "mount tag '%s' (%d bytes) is longer than " - "maximum (%d bytes)", s->fsconf.tag, len, MAX_TAG_LEN - 1); + error_setg(errp, "mount tag '%s' (%d bytes) is longer than " + "maximum (%d bytes)", s->fsconf.tag, len, MAX_TAG_LEN - 1); goto out; } @@ -99,12 +100,12 @@ static int virtio_9p_device_init(VirtIODevice *vdev) qemu_co_rwlock_init(&s->rename_lock); if (s->ops->init(&s->ctx) < 0) { - fprintf(stderr, "Virtio-9p Failed to initialize fs-driver with id:%s" - " and export path:%s\n", s->fsconf.fsdev_id, s->ctx.fs_root); + error_setg(errp, "Virtio-9p Failed to initialize fs-driver with id:%s" + " and export path:%s", s->fsconf.fsdev_id, s->ctx.fs_root); goto out; } if (v9fs_init_worker_threads() < 0) { - fprintf(stderr, "worker thread initialization failed\n"); + error_setg(errp, "worker thread initialization failed"); goto out; } @@ -114,28 +115,25 @@ static int virtio_9p_device_init(VirtIODevice *vdev) * use co-routines here. */ if (s->ops->name_to_path(&s->ctx, NULL, "/", &path) < 0) { - fprintf(stderr, - "error in converting name to path %s", strerror(errno)); + error_setg(errp, + "error in converting name to path %s", strerror(errno)); goto out; } if (s->ops->lstat(&s->ctx, &path, &stat)) { - fprintf(stderr, "share path %s does not exist\n", fse->path); + error_setg(errp, "share path %s does not exist", fse->path); goto out; } else if (!S_ISDIR(stat.st_mode)) { - fprintf(stderr, "share path %s is not a directory\n", fse->path); + error_setg(errp, "share path %s is not a directory", fse->path); goto out; } v9fs_path_free(&path); - return 0; + return; out: g_free(s->ctx.fs_root); g_free(s->tag); virtio_cleanup(vdev); v9fs_path_free(&path); - - return -1; - } /* virtio-9p device */ @@ -149,9 +147,10 @@ static void virtio_9p_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass); + dc->props = virtio_9p_properties; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); - vdc->init = virtio_9p_device_init; + vdc->realize = virtio_9p_device_realize; vdc->get_features = virtio_9p_get_features; vdc->get_config = virtio_9p_get_config; } -- 1.8.4.2