Commit 649a1bba authored by Peter Maydell's avatar Peter Maydell
Browse files

Merge remote-tracking branch 'remotes/kvaneesh/tags/for-upstream-signed' into staging



VirtFS update:

Cleanups mostly isolating virtio related details into separate files. This
is done to enable easy addition of Xen transport for VirtFS.

The changes include:

1. Rename a bunch of files and functions to make clear they are generic.
2. disentangle virtio transport code and generic 9pfs code.
3. Some function name clean-up.

# gpg: Signature made Tue 12 Jan 2016 06:04:35 GMT using RSA key ID 04C4E23A
# gpg: Good signature from "Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>"
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 4846 9DE7 1860 360F A6E9  968C DE41 A4FE 04C4 E23A

* remotes/kvaneesh/tags/for-upstream-signed: (25 commits)
  9pfs: introduce V9fsVirtioState
  9pfs: factor out v9fs_device_{,un}realize_common
  9pfs: rename virtio-9p.c to 9p.c
  9pfs: rename virtio_9p_set_fd_limit to use v9fs_ prefix
  9pfs: move handle_9p_output and make it static function
  9pfs: export pdu_{submit,alloc,free}
  9pfs: factor out virtio_9p_push_and_notify
  9pfs: break out 9p.h from virtio-9p.h
  9pfs: break out virtio_init_iov_from_pdu
  9pfs: factor out pdu_push_and_notify
  9pfs: factor out virtio_pdu_{,un}marshal
  9pfs: make pdu_{,un}marshal proper functions
  9pfs: PDU processing functions should start pdu_ prefix
  9pfs: PDU processing functions don't need to take V9fsState as argument
  fsdev: rename virtio-9p-marshal.{c,h} to 9p-iov-marshal.{c,h}
  fsdev: break out 9p-marshal.{c,h} from virtio-9p-marshal.{c,h}
  9pfs: remove dead code
  9pfs: merge hw/virtio/virtio-9p.h into hw/9pfs/virtio-9p.h
  9pfs: rename virtio-9p-xattr{,-user}.{c,h} to 9p-xattr{,-user}.{c,h}
  9pfs: rename virtio-9p-synth.{c,h} to 9p-synth.{c,h}
  ...

Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parents 8acc216b 00588a0a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -240,7 +240,7 @@ qemu-io$(EXESUF): qemu-io.o $(block-obj-y) $(crypto-obj-y) $(qom-obj-y) libqemuu

qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o

fsdev/virtfs-proxy-helper$(EXESUF): fsdev/virtfs-proxy-helper.o fsdev/virtio-9p-marshal.o libqemuutil.a libqemustub.a
fsdev/virtfs-proxy-helper$(EXESUF): fsdev/virtfs-proxy-helper.o fsdev/9p-marshal.o fsdev/9p-iov-marshal.o libqemuutil.a libqemustub.a
fsdev/virtfs-proxy-helper$(EXESUF): LIBS += -lcap

qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx
+86 −89
Original line number Diff line number Diff line
/*
 * Virtio 9p backend
 * 9p backend
 *
 * Copyright IBM, Corp. 2010
 *
@@ -22,40 +22,9 @@
#include <errno.h>

#include "qemu/compiler.h"
#include "virtio-9p-marshal.h"
#include "9p-iov-marshal.h"
#include "qemu/bswap.h"

void v9fs_string_free(V9fsString *str)
{
    g_free(str->data);
    str->data = NULL;
    str->size = 0;
}

void v9fs_string_null(V9fsString *str)
{
    v9fs_string_free(str);
}

void GCC_FMT_ATTR(2, 3)
v9fs_string_sprintf(V9fsString *str, const char *fmt, ...)
{
    va_list ap;

    v9fs_string_free(str);

    va_start(ap, fmt);
    str->size = g_vasprintf(&str->data, fmt, ap);
    va_end(ap);
}

void v9fs_string_copy(V9fsString *lhs, V9fsString *rhs)
{
    v9fs_string_free(lhs);
    v9fs_string_sprintf(lhs, "%s", rhs->data);
}


static ssize_t v9fs_packunpack(void *addr, struct iovec *sg, int sg_count,
                               size_t offset, size_t size, int pack)
{
@@ -107,15 +76,13 @@ ssize_t v9fs_pack(struct iovec *in_sg, int in_num, size_t offset,
    return v9fs_packunpack((void *)src, in_sg, in_num, offset, size, 1);
}

ssize_t v9fs_unmarshal(struct iovec *out_sg, int out_num, size_t offset,
                       int bswap, const char *fmt, ...)
ssize_t v9fs_iov_vunmarshal(struct iovec *out_sg, int out_num, size_t offset,
                            int bswap, const char *fmt, va_list ap)
{
    int i;
    va_list ap;
    ssize_t copied = 0;
    size_t old_offset = offset;

    va_start(ap, fmt);
    for (i = 0; fmt[i]; i++) {
        switch (fmt[i]) {
        case 'b': {
@@ -158,7 +125,7 @@ ssize_t v9fs_unmarshal(struct iovec *out_sg, int out_num, size_t offset,
        }
        case 's': {
            V9fsString *str = va_arg(ap, V9fsString *);
            copied = v9fs_unmarshal(out_sg, out_num, offset, bswap,
            copied = v9fs_iov_unmarshal(out_sg, out_num, offset, bswap,
                                        "w", &str->size);
            if (copied > 0) {
                offset += copied;
@@ -175,56 +142,70 @@ ssize_t v9fs_unmarshal(struct iovec *out_sg, int out_num, size_t offset,
        }
        case 'Q': {
            V9fsQID *qidp = va_arg(ap, V9fsQID *);
            copied = v9fs_unmarshal(out_sg, out_num, offset, bswap, "bdq",
                                    &qidp->type, &qidp->version, &qidp->path);
            copied = v9fs_iov_unmarshal(out_sg, out_num, offset, bswap,
                                        "bdq", &qidp->type, &qidp->version,
                                        &qidp->path);
            break;
        }
        case 'S': {
            V9fsStat *statp = va_arg(ap, V9fsStat *);
            copied = v9fs_unmarshal(out_sg, out_num, offset, bswap,
            copied = v9fs_iov_unmarshal(out_sg, out_num, offset, bswap,
                                        "wwdQdddqsssssddd",
                                    &statp->size, &statp->type, &statp->dev,
                                    &statp->qid, &statp->mode, &statp->atime,
                                        &statp->size, &statp->type,
                                        &statp->dev, &statp->qid,
                                        &statp->mode, &statp->atime,
                                        &statp->mtime, &statp->length,
                                    &statp->name, &statp->uid, &statp->gid,
                                    &statp->muid, &statp->extension,
                                        &statp->name, &statp->uid,
                                        &statp->gid, &statp->muid,
                                        &statp->extension,
                                        &statp->n_uid, &statp->n_gid,
                                        &statp->n_muid);
            break;
        }
        case 'I': {
            V9fsIattr *iattr = va_arg(ap, V9fsIattr *);
            copied = v9fs_unmarshal(out_sg, out_num, offset, bswap,
            copied = v9fs_iov_unmarshal(out_sg, out_num, offset, bswap,
                                        "ddddqqqqq",
                                        &iattr->valid, &iattr->mode,
                                    &iattr->uid, &iattr->gid, &iattr->size,
                                    &iattr->atime_sec, &iattr->atime_nsec,
                                    &iattr->mtime_sec, &iattr->mtime_nsec);
                                        &iattr->uid, &iattr->gid,
                                        &iattr->size, &iattr->atime_sec,
                                        &iattr->atime_nsec,
                                        &iattr->mtime_sec,
                                        &iattr->mtime_nsec);
            break;
        }
        default:
            break;
        }
        if (copied < 0) {
            va_end(ap);
            return copied;
        }
        offset += copied;
    }
    va_end(ap);

    return offset - old_offset;
}

ssize_t v9fs_marshal(struct iovec *in_sg, int in_num, size_t offset,
ssize_t v9fs_iov_unmarshal(struct iovec *out_sg, int out_num, size_t offset,
                           int bswap, const char *fmt, ...)
{
    int i;
    ssize_t ret;
    va_list ap;

    va_start(ap, fmt);
    ret = v9fs_iov_vunmarshal(out_sg, out_num, offset, bswap, fmt, ap);
    va_end(ap);

    return ret;
}

ssize_t v9fs_iov_vmarshal(struct iovec *in_sg, int in_num, size_t offset,
                          int bswap, const char *fmt, va_list ap)
{
    int i;
    ssize_t copied = 0;
    size_t old_offset = offset;

    va_start(ap, fmt);
    for (i = 0; fmt[i]; i++) {
        switch (fmt[i]) {
        case 'b': {
@@ -264,7 +245,7 @@ ssize_t v9fs_marshal(struct iovec *in_sg, int in_num, size_t offset,
        }
        case 's': {
            V9fsString *str = va_arg(ap, V9fsString *);
            copied = v9fs_marshal(in_sg, in_num, offset, bswap,
            copied = v9fs_iov_marshal(in_sg, in_num, offset, bswap,
                                      "w", str->size);
            if (copied > 0) {
                offset += copied;
@@ -274,17 +255,19 @@ ssize_t v9fs_marshal(struct iovec *in_sg, int in_num, size_t offset,
        }
        case 'Q': {
            V9fsQID *qidp = va_arg(ap, V9fsQID *);
            copied = v9fs_marshal(in_sg, in_num, offset, bswap, "bdq",
                                  qidp->type, qidp->version, qidp->path);
            copied = v9fs_iov_marshal(in_sg, in_num, offset, bswap, "bdq",
                                      qidp->type, qidp->version,
                                      qidp->path);
            break;
        }
        case 'S': {
            V9fsStat *statp = va_arg(ap, V9fsStat *);
            copied = v9fs_marshal(in_sg, in_num, offset, bswap,
            copied = v9fs_iov_marshal(in_sg, in_num, offset, bswap,
                                      "wwdQdddqsssssddd",
                                      statp->size, statp->type, statp->dev,
                                      &statp->qid, statp->mode, statp->atime,
                                  statp->mtime, statp->length, &statp->name,
                                      statp->mtime, statp->length,
                                      &statp->name,
                                      &statp->uid, &statp->gid, &statp->muid,
                                      &statp->extension, statp->n_uid,
                                      statp->n_gid, statp->n_muid);
@@ -292,7 +275,7 @@ ssize_t v9fs_marshal(struct iovec *in_sg, int in_num, size_t offset,
        }
        case 'A': {
            V9fsStatDotl *statp = va_arg(ap, V9fsStatDotl *);
            copied = v9fs_marshal(in_sg, in_num, offset, bswap,
            copied = v9fs_iov_marshal(in_sg, in_num, offset, bswap,
                                      "qQdddqqqqqqqqqqqqqqq",
                                      statp->st_result_mask,
                                      &statp->qid, statp->st_mode,
@@ -300,9 +283,12 @@ ssize_t v9fs_marshal(struct iovec *in_sg, int in_num, size_t offset,
                                      statp->st_nlink, statp->st_rdev,
                                      statp->st_size, statp->st_blksize,
                                      statp->st_blocks, statp->st_atime_sec,
                                   statp->st_atime_nsec, statp->st_mtime_sec,
                                   statp->st_mtime_nsec, statp->st_ctime_sec,
                                   statp->st_ctime_nsec, statp->st_btime_sec,
                                      statp->st_atime_nsec,
                                      statp->st_mtime_sec,
                                      statp->st_mtime_nsec,
                                      statp->st_ctime_sec,
                                      statp->st_ctime_nsec,
                                      statp->st_btime_sec,
                                      statp->st_btime_nsec, statp->st_gen,
                                      statp->st_data_version);
            break;
@@ -311,12 +297,23 @@ ssize_t v9fs_marshal(struct iovec *in_sg, int in_num, size_t offset,
            break;
        }
        if (copied < 0) {
            va_end(ap);
            return copied;
        }
        offset += copied;
    }
    va_end(ap);

    return offset - old_offset;
}

ssize_t v9fs_iov_marshal(struct iovec *in_sg, int in_num, size_t offset,
                         int bswap, const char *fmt, ...)
{
    ssize_t ret;
    va_list ap;

    va_start(ap, fmt);
    ret = v9fs_iov_vmarshal(in_sg, in_num, offset, bswap, fmt, ap);
    va_end(ap);

    return ret;
}

fsdev/9p-iov-marshal.h

0 → 100644
+18 −0
Original line number Diff line number Diff line
#ifndef _QEMU_9P_IOV_MARSHAL_H
#define _QEMU_9P_IOV_MARSHAL_H

#include "9p-marshal.h"


ssize_t v9fs_pack(struct iovec *in_sg, int in_num, size_t offset,
                  const void *src, size_t size);
ssize_t v9fs_iov_unmarshal(struct iovec *out_sg, int out_num, size_t offset,
                           int bswap, const char *fmt, ...);
ssize_t v9fs_iov_marshal(struct iovec *in_sg, int in_num, size_t offset,
                         int bswap, const char *fmt, ...);

ssize_t v9fs_iov_vunmarshal(struct iovec *out_sg, int out_num, size_t offset,
                            int bswap, const char *fmt, va_list ap);
ssize_t v9fs_iov_vmarshal(struct iovec *in_sg, int in_num, size_t offset,
                          int bswap, const char *fmt, va_list ap);
#endif

fsdev/9p-marshal.c

0 → 100644
+56 −0
Original line number Diff line number Diff line
/*
 * 9p backend
 *
 * Copyright IBM, Corp. 2010
 *
 * Authors:
 *  Anthony Liguori   <aliguori@us.ibm.com>
 *
 * This work is licensed under the terms of the GNU GPL, version 2.  See
 * the COPYING file in the top-level directory.
 *
 */

#include <glib.h>
#include <glib/gprintf.h>
#include <sys/types.h>
#include <dirent.h>
#include <sys/time.h>
#include <utime.h>
#include <sys/uio.h>
#include <string.h>
#include <stdint.h>
#include <errno.h>

#include "qemu/compiler.h"
#include "9p-marshal.h"

void v9fs_string_free(V9fsString *str)
{
    g_free(str->data);
    str->data = NULL;
    str->size = 0;
}

void v9fs_string_null(V9fsString *str)
{
    v9fs_string_free(str);
}

void GCC_FMT_ATTR(2, 3)
v9fs_string_sprintf(V9fsString *str, const char *fmt, ...)
{
    va_list ap;

    v9fs_string_free(str);

    va_start(ap, fmt);
    str->size = g_vasprintf(&str->data, fmt, ap);
    va_end(ap);
}

void v9fs_string_copy(V9fsString *lhs, V9fsString *rhs)
{
    v9fs_string_free(lhs);
    v9fs_string_sprintf(lhs, "%s", rhs->data);
}
+3 −9
Original line number Diff line number Diff line
#ifndef _QEMU_VIRTIO_9P_MARSHAL_H
#define _QEMU_VIRTIO_9P_MARSHAL_H
#ifndef _QEMU_9P_MARSHAL_H
#define _QEMU_9P_MARSHAL_H

typedef struct V9fsString
{
@@ -81,10 +81,4 @@ extern void v9fs_string_null(V9fsString *str);
extern void v9fs_string_sprintf(V9fsString *str, const char *fmt, ...);
extern void v9fs_string_copy(V9fsString *lhs, V9fsString *rhs);

ssize_t v9fs_pack(struct iovec *in_sg, int in_num, size_t offset,
                  const void *src, size_t size);
ssize_t v9fs_unmarshal(struct iovec *out_sg, int out_num, size_t offset,
                       int bswap, const char *fmt, ...);
ssize_t v9fs_marshal(struct iovec *in_sg, int in_num, size_t offset,
                     int bswap, const char *fmt, ...);
#endif
Loading