On Thu, Feb 06, 2014 at 11:48:51AM -0500, Marcelo Tosatti wrote: > > > Require a minimal pagesize for hugetlbfs backed guests. Fail guest initialization > if hugetlbfs mount is configured with smaller page size. > > Signed-off-by: Marcelo Tosatti <mtosatti@xxxxxxxxxx> > > > +#ifdef __linux__ > + > +#include <sys/vfs.h> > + > +#define HUGETLBFS_MAGIC 0x958458f6 > + > +static long gethugepagesize(const char *path) > +{ > + struct statfs fs; > + int ret; > + > + do { > + ret = statfs(path, &fs); > + } while (ret != 0 && errno == EINTR); > + > + if (ret != 0) { > + perror(path); > + return 0; > + } > + > + if (fs.f_type != HUGETLBFS_MAGIC) > + return 0; > + > + return fs.f_bsize; > +} > +#endif > + > > int qemuProcessStart(virConnectPtr conn, > virQEMUDriverPtr driver, > @@ -3712,6 +3739,31 @@ int qemuProcessStart(virConnectPtr conn, > "%s", _("Unable to set huge path in security driver")); > goto cleanup; > } > + > + if (vm->def->mem.page_size) { > +#ifdef __linux__ > + unsigned long hpagesize = gethugepagesize(cfg->hugepagePath); > + > + if (!hpagesize) { > + virReportError(VIR_ERR_INTERNAL_ERROR, > + "%s", _("Unable to stat hugepage path")); > + goto cleanup; > + } > + > + hpagesize /= 1024; > + > + if (hpagesize < vm->def->mem.page_size) { > + virReportError(VIR_ERR_INTERNAL_ERROR, > + _("Error: hugetlbfs page size=%ld < pagesize=%lld"), > + hpagesize, vm->def->mem.page_size); > + goto cleanup; > + } > +#else > + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, > + "%s", _("pagesize option unsupported")); > + goto cleanup; > +#endif > + } > } IMHO all of this code is something that belongs in QEMU, with libvirt telling QEMU what min page size it wants via a CLI arg. 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