Re: [PATCH 4/4] qemu: call the helpers in virshm.c to manage shmem device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jul 23, 2015 at 06:13:49PM +0800, Luyao Huang wrote:
> Signed-off-by: Luyao Huang <lhuang@xxxxxxxxxx>
> ---
>  src/qemu/qemu_conf.h    |   3 +
>  src/qemu/qemu_driver.c  |   4 ++
>  src/qemu/qemu_process.c | 158 ++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 165 insertions(+)
> 

> +static int
> +qemuPrepareShmemDevice(virQEMUDriverPtr driver,
> +                       virDomainObjPtr vm,
> +                       virDomainShmemDefPtr shmem)
> +{
> +    int ret = -1;
> +    virShmObjectPtr tmp;
> +    virShmObjectListPtr list = driver->shmlist;
> +    bool othercreate = false;
> +    char *path = NULL;
> +    bool teardownlabel = false;
> +    bool teardownshm = false;
> +    int type, fd;
> +
> +    virObjectLock(list);
> +
> +    if ((tmp = virShmObjectFindByName(list, shmem->name))) {
> +        if (shmem->size > tmp->size) {
> +            virReportError(VIR_ERR_INTERNAL_ERROR,
> +                           _("Shmem object %s is already exists and "
> +                             "size is smaller than require size"),
> +                           tmp->name);
> +            goto cleanup;
> +        }
> +
> +        if (virShmSetUsedDomain(tmp, QEMU_DRIVER_NAME, vm->def->name) < 0)
> +            goto cleanup;
> +
> +        if (virShmObjectSaveState(tmp, list->stateDir) < 0)
> +            goto cleanup;
> +
> +        virObjectUnlock(list);
> +        return 0;
> +    }
> +
> +    if (!shmem->server.enabled) {
> +        if ((fd = virShmCreate(shmem->name, shmem->size, false, &othercreate, 0600)) < 0)
> +            goto cleanup;
> +        VIR_FORCE_CLOSE(fd);
> +
> +        if ((ret = virShmBuildPath(shmem->name, &path)) == -1) {
> +            ignore_value(virShmUnlink(shmem->name));
> +            goto cleanup;
> +        } else if (ret == -2 && !othercreate) {
> +            ignore_value(virShmUnlink(shmem->name));

Why are you treating -1 differentl from -2 - in both cases we should
abort creation as that indicates the method either failed or is not
supported in this platform.

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]