[PATCH 1/5] qemuOpenFileAs: Move into util/virqemu.c

Peter Krempa pkrempa at redhat.com
Mon Aug 24 15:24:51 UTC 2020


On Mon, Aug 24, 2020 at 16:18:40 +0100, Daniel Berrange wrote:
> On Thu, Aug 06, 2020 at 11:55:12AM +0200, Peter Krempa wrote:
> > Signed-off-by: Peter Krempa <pkrempa at redhat.com>
> > ---
> >  src/libvirt_private.syms |   1 +
> >  src/qemu/qemu_driver.c   | 138 ++-------------------------------------
> >  src/util/virqemu.c       | 130 ++++++++++++++++++++++++++++++++++++
> >  src/util/virqemu.h       |   7 ++
> >  4 files changed, 144 insertions(+), 132 deletions(-)
> 
> The original source files were not built on Win32, the new
> source files are. This causes a build failure due to...

Sigh. I thought that I could make it to be an universal helper. Not very
useful, but universal.

An alternative solution could be to dump it to qemu_domain.c ...

> 
> > diff --git a/src/util/virqemu.c b/src/util/virqemu.c
> > index 20cb09d878..e1c8673390 100644
> > --- a/src/util/virqemu.c
> > +++ b/src/util/virqemu.c
> > @@ -22,12 +22,18 @@
> > 
> >  #include <config.h>
> > 
> > +#include <sys/types.h>
> > +#include <sys/stat.h>
> > +#include <fcntl.h>
> > +#include <unistd.h>
> > +
> >  #include "virbuffer.h"
> >  #include "virerror.h"
> >  #include "virlog.h"
> >  #include "virqemu.h"
> >  #include "virstring.h"
> >  #include "viralloc.h"
> > +#include "virfile.h"
> > 
> >  #define VIR_FROM_THIS VIR_FROM_NONE
> > 
> > @@ -441,3 +447,127 @@ virQEMUBuildQemuImgKeySecretOpts(virBufferPtr buf,
> >          virBufferAddLit(buf, ",");
> >      }
> >  }
> > +
> > +
> > +int
> > +virQEMUFileOpenAs(uid_t fallback_uid,
> > +                  gid_t fallback_gid,
> > +                  bool dynamicOwnership,
> > +                  const char *path,
> > +                  int oflags,
> > +                  bool *needUnlink)
> > +{
> > +    struct stat sb;
> > +    bool is_reg = true;
> > +    bool need_unlink = false;
> > +    unsigned int vfoflags = 0;
> > +    int fd = -1;
> > +    int path_shared = virFileIsSharedFS(path);
> > +    uid_t uid = geteuid();
> > +    gid_t gid = getegid();
> 
> ... these calls
> 
> 
> We'll need to provide a  stub that raises an error on win32 for this.

... to avoid a need for this. It's not as universal of a helper anyways.




More information about the libvir-list mailing list