On Thu, Nov 15, 2018 at 11:20:37AM +0000, Wei Liu wrote: > On Thu, Nov 15, 2018 at 10:45:52AM +0000, Edwin Török wrote: > > On 14/11/2018 18:17, Wei Liu wrote: > > > Read from XEN_CONFIG_DIR/dom0-uuid. If it contains a valid UUID, set > > > it for Dom0. > > > > > > Signed-off-by: Wei Liu <wei.l...@citrix.com> > > > > [snip] > > In general this looks good, however I am not familiar with libxl > > conventions, so just some generic comments below. > > > > > +static void get_dom0_uuid(libxl_uuid *uuid) > > > +{ > > > + int fd = -1; > > > + ssize_t r; > > > + char uuid_buf[LIBXL_UUID_FMTLEN+1]; > > > + > > > + libxl_uuid_clear(uuid); > > > + > > > + fd = open(DOM0_UUID_PATH, O_RDONLY); > > > + if (fd < 0) { > > > + fprintf(stderr, "failed to open %s\n", DOM0_UUID_PATH); > > > + goto out; > > > + } > > > + > > > + r = read(fd, uuid_buf, LIBXL_UUID_FMTLEN); > > > > Could this be a short read? I'm not familiar with libxl conventions, but > > would there be a utility function that repeats the read if it is short, > > or would fread be better? > > I can use libxl_read_exactly instead. That saves me from writing some > code to handle every corner case. >
On second thought, this requires code to allocating and destroying libxl ctx. I will write a loop here to handle short-read instead. Wei. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel