All of lore.kernel.org
 help / color / mirror / Atom feed
From: Haozhong Zhang <haozhong.zhang@intel.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: qemu-devel@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>,
	Igor Mammedov <imammedo@redhat.com>,
	Xiao Guangrong <guangrong.xiao@gmail.com>,
	Dan Williams <dan.j.williams@intel.com>
Subject: Re: [Qemu-devel] [PATCH v2 2/4] nvdimm: warn if the backend is not a DAX device
Date: Thu, 8 Jun 2017 09:07:48 +0800	[thread overview]
Message-ID: <20170608010748.jqcdbcnt44pvqjsr@hz-desktop> (raw)
In-Reply-To: <20170607151445.GE21990@stefanha-x1.localdomain>

On 06/07/17 16:14 +0100, Stefan Hajnoczi wrote:
> On Tue, Jun 06, 2017 at 03:22:27PM +0800, Haozhong Zhang wrote:
> > diff --git a/util/osdep.c b/util/osdep.c
> > index a2863c8e53..02881f96bc 100644
> > --- a/util/osdep.c
> > +++ b/util/osdep.c
> > @@ -471,3 +471,64 @@ writev(int fd, const struct iovec *iov, int iov_cnt)
> >      return readv_writev(fd, iov, iov_cnt, true);
> >  }
> >  #endif
> > +
> > +#ifdef __linux__
> > +static ssize_t qemu_dev_dax_sysfs_read(int fd, const char *entry,
> > +                                       char *buf, size_t len)
> > +{
> > +    ssize_t read_bytes;
> > +    struct stat st;
> > +    unsigned int major, minor;
> > +    char *path, *pos;
> > +    int sysfs_fd;
> > +
> > +    if (fstat(fd, &st)) {
> > +        return 0;
> > +    }
> > +
> > +    major = major(st.st_rdev);
> > +    minor = minor(st.st_rdev);
> > +    path = g_strdup_printf("/sys/dev/char/%u:%u/%s", major, minor, entry);
> > +
> > +    sysfs_fd = open(path, O_RDONLY);
> > +    g_free(path);
> > +    if (sysfs_fd == -1) {
> > +        return 0;
> > +    }
> > +
> > +    read_bytes = read(sysfs_fd, buf, len - 1);
> > +    close(sysfs_fd);
> > +    if (read_bytes > 0) {
> > +        buf[read_bytes] = '\0';
> > +        pos = g_strstr_len(buf, read_bytes, "\n");
> > +        if (pos) {
> > +            *pos = '\0';
> > +        }
> 
> Should read_bytes be adjusted since we made the string shorter?

Yes, I'll change in the next version.

Thanks,
Haozhong

  reply	other threads:[~2017-06-08  1:07 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-06  7:22 [Qemu-devel] [PATCH v2 0/4] nvdimm: fixes for (non-)dax backends Haozhong Zhang
2017-06-06  7:22 ` [Qemu-devel] [PATCH v2 1/4] nvdimm: add a macro for property "label-size" Haozhong Zhang
2017-06-07 15:29   ` Stefan Hajnoczi
2017-06-06  7:22 ` [Qemu-devel] [PATCH v2 2/4] nvdimm: warn if the backend is not a DAX device Haozhong Zhang
2017-06-06 17:59   ` Dan Williams
2017-06-08  1:07     ` Haozhong Zhang
2017-06-07 15:14   ` Stefan Hajnoczi
2017-06-08  1:07     ` Haozhong Zhang [this message]
2017-06-08 12:51   ` Michael S. Tsirkin
2017-06-12  3:18     ` Haozhong Zhang
2017-06-12  3:25       ` Michael S. Tsirkin
2017-06-06  7:22 ` [Qemu-devel] [PATCH v2 3/4] nvdimm: add a boolean option "restrict" Haozhong Zhang
2017-06-07 15:27   ` Stefan Hajnoczi
2017-06-08  1:45     ` Haozhong Zhang
2017-06-08 10:19       ` Stefan Hajnoczi
2017-06-08  6:39     ` Haozhong Zhang
2017-06-08 10:18       ` Stefan Hajnoczi
2017-06-08 12:56   ` Michael S. Tsirkin
2017-06-09  9:34     ` Stefan Hajnoczi
2017-06-12  1:18     ` Haozhong Zhang
2017-06-06  7:22 ` [Qemu-devel] [PATCH v2 4/4] util/mmap-alloc: account for DAX device in qemu_fd_getpagesize Haozhong Zhang
2017-06-07 15:29   ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170608010748.jqcdbcnt44pvqjsr@hz-desktop \
    --to=haozhong.zhang@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=guangrong.xiao@gmail.com \
    --cc=imammedo@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.