On Tue, Feb 04, 2020 at 05:36:23PM +0100, Ján Tomko wrote:
> On Mon, Feb 03, 2020 at 10:16:29PM -0500, Masayoshi Mizuma wrote:
> > On Thu, Jan 30, 2020 at 06:06:26PM +0100, Ján Tomko wrote:
> > > Start virtiofsd for each <filesystem> device using it.
> > > 
> > > Pre-create the socket for communication with QEMU and pass it
> > > to virtiofsd.
> > > 
> > > Note that virtiofsd needs to run as root.
> > > 
> > > https://bugzilla.redhat.com/show_bug.cgi?id=1694166
> > > 
> > > Introduced by QEMU commit a43efa34c7d7b628cbf1ec0fe60043e5c91043ea
> > > 
> > > Signed-off-by: Ján Tomko <jto...@redhat.com>
> > > ---
> > >  po/POTFILES.in            |   1 +
> > >  src/qemu/Makefile.inc.am  |   2 +
> > >  src/qemu/qemu_domain.c    |   5 +-
> > >  src/qemu/qemu_domain.h    |   2 +-
> > >  src/qemu/qemu_extdevice.c |  20 ++-
> > >  src/qemu/qemu_virtiofs.c  | 290 ++++++++++++++++++++++++++++++++++++++
> > >  src/qemu/qemu_virtiofs.h  |  38 +++++
> > >  tests/qemuxml2argvtest.c  |  11 ++
> > >  8 files changed, 366 insertions(+), 3 deletions(-)
> > >  create mode 100644 src/qemu/qemu_virtiofs.c
> > >  create mode 100644 src/qemu/qemu_virtiofs.h
> > > 
> > > diff --git a/po/POTFILES.in b/po/POTFILES.in
> > > index c18e21615f..813fb24199 100644
> > > --- a/po/POTFILES.in
> > > +++ b/po/POTFILES.in
> > > @@ -168,6 +168,7 @@
> > >  @SRCDIR@/src/qemu/qemu_tpm.c
> > >  @SRCDIR@/src/qemu/qemu_vhost_user.c
> > >  @SRCDIR@/src/qemu/qemu_vhost_user_gpu.c
> > > +@SRCDIR@/src/qemu/qemu_virtiofs.c
> > >  @SRCDIR@/src/remote/remote_daemon.c
> > >  @SRCDIR@/src/remote/remote_daemon_config.c
> > >  @SRCDIR@/src/remote/remote_daemon_dispatch.c
> > > diff --git a/src/qemu/Makefile.inc.am b/src/qemu/Makefile.inc.am
> > > index d04a87e659..7a205b4da6 100644
> > > --- a/src/qemu/Makefile.inc.am
> > > +++ b/src/qemu/Makefile.inc.am
> > > @@ -67,6 +67,8 @@ QEMU_DRIVER_SOURCES = \
> > >   qemu/qemu_vhost_user.h \
> > >   qemu/qemu_vhost_user_gpu.c \
> > >   qemu/qemu_vhost_user_gpu.h \
> > > + qemu/qemu_virtiofs.c \
> > > + qemu/qemu_virtiofs.h \
> > >   qemu/qemu_checkpoint.c \
> > >   qemu/qemu_checkpoint.h \
> > >   qemu/qemu_backup.c \
> > > diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> > > index b5d5812ff8..3064c33ca8 100644
> > > --- a/src/qemu/qemu_domain.c
> > > +++ b/src/qemu/qemu_domain.c
> > > @@ -1440,8 +1440,11 @@ qemuDomainFSPrivateNew(void)
> > > 
> > > 
> > >  static void
> > > -qemuDomainFSPrivateDispose(void *obj G_GNUC_UNUSED)
> > > +qemuDomainFSPrivateDispose(void *obj)
> > >  {
> > > +    qemuDomainFSPrivatePtr priv = obj;
> > > +
> > > +    g_free(priv->vhostuser_fs_sock);
> > >  }
> > 
> > How about adding close the logfile fd here?
> > That is because virtlogd keeps opening the fd even after the guest is
> 
> Thanks for catching that.
> 
> Currently libvirtd does not access the log after starting up the
> virtiofsd so all that is needed is to close it in this function:
> 
> diff --git a/src/qemu/qemu_virtiofs.c b/src/qemu/qemu_virtiofs.c
> index e0683d6468..067cef7e22 100644
> --- a/src/qemu/qemu_virtiofs.c
> +++ b/src/qemu/qemu_virtiofs.c
> @@ -217,7 +217,6 @@ qemuVirtioFSStart(virLogManagerPtr logManager,
>          goto cleanup;
> 
>      rc = virCommandRun(cmd, NULL);
> -    logfd = -1;
> 
>      if (rc < 0) {
>          virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> 
> (and the VIR_AUTOCLOSE attribute will take care of closing it when it
> goes out of scope)

Great, it works!

- Masa


Reply via email to