On 06/22/2017 12:18 PM, Michal Privoznik wrote:
> Currently, we silently assume that file we are creating in the
> namespace is either a link or a device (character or block one).
> This is not always the case. Therefore instead of doing something
> wrong, claim about unsupported file type.
>
> Signed-off-by: Michal Privoznik
> ---
> src/qemu/qemu_domain.c | 8 +++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
Similar comment about print style for octal value %o
Reviewed-by: John Ferlan
John
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index e6fb041de..977b5c089 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -8518,6 +8518,7 @@ qemuDomainAttachDeviceMknodHelper(pid_t pid
> ATTRIBUTE_UNUSED,
> int ret = -1;
> bool delDevice = false;
> bool isLink = S_ISLNK(data->sb.st_mode);
> +bool isDev = S_ISCHR(data->sb.st_mode) || S_ISBLK(data->sb.st_mode);
>
> qemuSecurityPostFork(data->driver->securityManager);
>
> @@ -8539,7 +8540,7 @@ qemuDomainAttachDeviceMknodHelper(pid_t pid
> ATTRIBUTE_UNUSED,
> } else {
> delDevice = true;
> }
> -} else {
> +} else if (isDev) {
> VIR_DEBUG("Creating dev %s (%d,%d)",
>data->file, major(data->sb.st_rdev),
> minor(data->sb.st_rdev));
> if (mknod(data->file, data->sb.st_mode, data->sb.st_rdev) < 0) {
> @@ -8556,6 +8557,11 @@ qemuDomainAttachDeviceMknodHelper(pid_t pid
> ATTRIBUTE_UNUSED,
> } else {
> delDevice = true;
> }
> +} else {
> +virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
> + _("unsupported device type %s %o"),
^^
s/%o/0%o
> + data->file, (int) data->sb.st_mode);
> +goto cleanup;
> }
>
> if (lchown(data->file, data->sb.st_uid, data->sb.st_gid) < 0) {
>
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list