[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 55/61] virtio-9p : cleanup : init function.
From: |
fred . konrad |
Subject: |
[Qemu-devel] [PATCH 55/61] virtio-9p : cleanup : init function. |
Date: |
Mon, 7 Jan 2013 19:41:08 +0100 |
From: KONRAD Frederic <address@hidden>
This remove old init function as it is no longer needed. This shouldn't
been applyied before virtio-9p-pci refactoring.
Signed-off-by: KONRAD Frederic <address@hidden>
---
hw/9pfs/virtio-9p-device.c | 75 ++++++++++++++--------------------------------
1 file changed, 23 insertions(+), 52 deletions(-)
diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c
index 7e4b239..02f01ae 100644
--- a/hw/9pfs/virtio-9p-device.c
+++ b/hw/9pfs/virtio-9p-device.c
@@ -52,30 +52,17 @@ void virtio_9p_set_conf(DeviceState *dev, V9fsConf *conf)
memcpy(&(s->fsconf), conf, sizeof(V9fsConf));
}
-static VirtIODevice *virtio_9p_common_init(DeviceState *dev, V9fsConf *conf,
- V9fsState **ps)
+static int virtio_9p_device_init(VirtIODevice *vdev)
{
- V9fsState *s = *ps;
+ V9fsState *s = VIRTIO_9P(vdev);
int i, len;
struct stat stat;
FsDriverEntry *fse;
V9fsPath path;
- /*
- * We have two cases here : the old virtio-9p-pci device, and the
- * refactored virtio-9p.
- */
+ virtio_init(VIRTIO_DEVICE(s), "virtio-9p", VIRTIO_ID_9P,
+ sizeof(struct virtio_9p_config) + MAX_TAG_LEN);
- if (s == NULL) {
- s = (V9fsState *)virtio_common_init("virtio-9p",
- VIRTIO_ID_9P,
- sizeof(struct virtio_9p_config)+
- MAX_TAG_LEN,
- sizeof(V9fsState));
- } else {
- virtio_init(VIRTIO_DEVICE(s), "virtio-9p", VIRTIO_ID_9P,
- sizeof(struct virtio_9p_config) + MAX_TAG_LEN);
- }
/* initialize pdu allocator */
QLIST_INIT(&s->free_list);
QLIST_INIT(&s->active_list);
@@ -83,22 +70,23 @@ static VirtIODevice *virtio_9p_common_init(DeviceState
*dev, V9fsConf *conf,
QLIST_INSERT_HEAD(&s->free_list, &s->pdus[i], next);
}
- s->vq = virtio_add_queue(&s->vdev, MAX_REQ, handle_9p_output);
+ s->vq = virtio_add_queue(vdev, MAX_REQ, handle_9p_output);
- fse = get_fsdev_fsentry(conf->fsdev_id);
+ fse = get_fsdev_fsentry(s->fsconf.fsdev_id);
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", conf->fsdev_id ? conf->fsdev_id : "NULL");
- exit(1);
+ "id = %s\n",
+ s->fsconf.fsdev_id ? s->fsconf.fsdev_id : "NULL");
+ return -1;
}
- if (!conf->tag) {
+ if (!s->fsconf.tag) {
/* we haven't specified a mount_tag */
fprintf(stderr, "fsdev with id %s needs mount_tag arguments\n",
- conf->fsdev_id);
- exit(1);
+ s->fsconf.fsdev_id);
+ return -1;
}
s->ctx.export_flags = fse->export_flags;
@@ -108,14 +96,14 @@ static VirtIODevice *virtio_9p_common_init(DeviceState
*dev, V9fsConf *conf,
s->ctx.fs_root = NULL;
}
s->ctx.exops.get_st_gen = NULL;
- len = strlen(conf->tag);
+ len = strlen(s->fsconf.tag);
if (len > MAX_TAG_LEN - 1) {
fprintf(stderr, "mount tag '%s' (%d bytes) is longer than "
- "maximum (%d bytes)", conf->tag, len, MAX_TAG_LEN - 1);
- exit(1);
+ "maximum (%d bytes)", s->fsconf.tag, len, MAX_TAG_LEN - 1);
+ return -1;
}
- s->tag = strdup(conf->tag);
+ s->tag = strdup(s->fsconf.tag);
s->ctx.uid = -1;
s->ops = fse->ops;
@@ -127,12 +115,12 @@ static VirtIODevice *virtio_9p_common_init(DeviceState
*dev, V9fsConf *conf,
if (s->ops->init(&s->ctx) < 0) {
fprintf(stderr, "Virtio-9p Failed to initialize fs-driver with id:%s"
- " and export path:%s\n", conf->fsdev_id, s->ctx.fs_root);
- exit(1);
+ " and export path:%s\n", s->fsconf.fsdev_id, s->ctx.fs_root);
+ return -1;
}
if (v9fs_init_worker_threads() < 0) {
fprintf(stderr, "worker thread initialization failed\n");
- exit(1);
+ return -1;
}
/*
@@ -144,24 +132,18 @@ static VirtIODevice *virtio_9p_common_init(DeviceState
*dev, V9fsConf *conf,
if (s->ops->name_to_path(&s->ctx, NULL, "/", &path) < 0) {
fprintf(stderr,
"error in converting name to path %s", strerror(errno));
- exit(1);
+ return -1;
}
if (s->ops->lstat(&s->ctx, &path, &stat)) {
fprintf(stderr, "share path %s does not exist\n", fse->path);
- exit(1);
+ return -1;
} else if (!S_ISDIR(stat.st_mode)) {
fprintf(stderr, "share path %s is not a directory\n", fse->path);
- exit(1);
+ return -1;
}
v9fs_path_free(&path);
- return &s->vdev;
-}
-
-VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf)
-{
- V9fsState *s = NULL;
- return virtio_9p_common_init(dev, conf, &s);
+ return 0;
}
static int virtio_9p_init_pci(VirtIOPCIProxy *vpci_dev)
@@ -212,17 +194,6 @@ static TypeInfo virtio_9p_pci_info = {
/* virtio-9p device */
-static int virtio_9p_device_init(VirtIODevice *vdev)
-{
- DeviceState *qdev = DEVICE(vdev);
- V9fsState *s = VIRTIO_9P(vdev);
- V9fsConf *fsconf = &(s->fsconf);
- if (virtio_9p_common_init(qdev, fsconf, &s) == NULL) {
- return -1;
- }
- return 0;
-}
-
static Property virtio_9p_properties[] = {
DEFINE_VIRTIO_9P_PROPERTIES(V9fsState, fsconf),
DEFINE_PROP_END_OF_LIST(),
--
1.7.11.7
- [Qemu-devel] [PATCH 47/61] virtio-serial : add the virtio-serial device., (continued)
- [Qemu-devel] [PATCH 47/61] virtio-serial : add the virtio-serial device., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 61/61] virtio : cleanup : init and exit function., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 51/61] virtio-serial : cleanup : use QOM casts., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 56/61] virtio-9p : cleanup : QOM casts., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 59/61] s390-virtio-bus : cleanup, fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 57/61] virtio : remove the function pointer., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 22/61] virtio-scsi : show the VirtIOSCSI structure., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 58/61] virtio-pci : cleanup : init, exit and reset functions., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 53/61] virtio-9p : add the virtio-9p device., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 25/61] virtio-scsi : moving host_features from properties to transport properties., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 55/61] virtio-9p : cleanup : init function.,
fred . konrad <=
- [Qemu-devel] [PATCH 54/61] virtio-9p-pci : switch to the new API., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 60/61] virtio : remove virtiobindings., fred . konrad, 2013/01/07
- Re: [Qemu-devel] [PATCH 00/61] Virtio refactoring., Anthony Liguori, 2013/01/07
- [Qemu-devel] [PATCH 44/61] virtio-rng.c : cleanup : remove qdev field., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 26/61] virtio-scsi : add the virtio-scsi device., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 24/61] virtio-scsi : allocate cmd_vqs array separately., fred . konrad, 2013/01/07