diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk index d47a92b530..bf229c42a7 100644 --- a/build-aux/syntax-check.mk +++ b/build-aux/syntax-check.mk @@ -1869,8 +1869,8 @@ sc_po_check: gen_source_files { $(VC_LIST_EXCEPT); echo $(generated_files); } \ | xargs perl $(perl_translatable_files_list_) \ | xargs $(GREP) -E -l '$(_gl_translatable_string_re)' \ - | $(SED) 's|^$(_dot_escaped_srcdir)|@SRCDIR@|' \ - | $(SED) 's|^$(_dot_escaped_builddir)|@BUILDDIR@|' \ + | $(SED) 's|^$(_dot_escaped_srcdir)/|@SRCDIR@|' \ + | $(SED) 's|^$(_dot_escaped_builddir)/|@BUILDDIR@|' \ | sort -u > $@-2; \ diff -u -L $(po_file) -L $(po_file) $@-1 $@-2 \ || { printf '$(ME): '$(fix_po_file_diag) 1>&2; exit 1; }; \ diff --git a/po/Makefile.am b/po/Makefile.am index 95294aa12e..f0698b455b 100644 --- a/po/Makefile.am +++ b/po/Makefile.am @@ -7,8 +7,8 @@ LANGS := $(shell cat $(srcdir)/LINGUAS) POTFILES_IN = $(srcdir)/POTFILES.in POTFILES: $(POTFILES_IN) $(AM_V_GEN) cat $(POTFILES_IN) | \ - $(SED) 's|[@]SRCDIR[@]|$(top_srcdir)|' | \ - $(SED) 's|[@]BUILDDIR[@]|$(top_builddir)|' > $@ + $(SED) 's|[@]SRCDIR[@]||' | \ + $(SED) 's|[@]BUILDDIR[@]||' > $@ POTFILE_DEPS = $(shell cat POTFILES) POTFILE := $(DOMAIN).pot POFILES := $(LANGS:%=%.po) @@ -32,6 +32,8 @@ XGETTEXT_ARGS = \ --package-name="$(PACKAGE_NAME)" \ --package-version="$(PACKAGE_VERSION)" \ --msgid-bugs-address="$(MSGID_BUGS_ADDRESS)" \ + --directory="$(top_srcdir)" \ + --directory="$(top_builddir)" \ --sort-output \ $(NULL) diff --git a/po/POTFILES.in b/po/POTFILES.in index af52054aa4..0498a0e819 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,363 +1,364 @@ -@BUILDDIR@/src/access/viraccessapicheck.c -@BUILDDIR@/src/access/viraccessapichecklxc.c -@BUILDDIR@/src/access/viraccessapicheckqemu.c -@BUILDDIR@/src/admin/admin_client.h -@BUILDDIR@/src/admin/admin_server_dispatch_stubs.h -@BUILDDIR@/src/remote/remote_client_bodies.h -@BUILDDIR@/src/remote/remote_daemon_dispatch_stubs.h -@SRCDIR@/src/access/viraccessdriverpolkit.c -@SRCDIR@/src/access/viraccessmanager.c -@SRCDIR@/src/admin/admin_server.c -@SRCDIR@/src/admin/admin_server_dispatch.c -@SRCDIR@/src/admin/libvirt-admin.c -@SRCDIR@/src/bhyve/bhyve_capabilities.c -@SRCDIR@/src/bhyve/bhyve_command.c -@SRCDIR@/src/bhyve/bhyve_device.c -@SRCDIR@/src/bhyve/bhyve_domain.c -@SRCDIR@/src/bhyve/bhyve_driver.c -@SRCDIR@/src/bhyve/bhyve_monitor.c -@SRCDIR@/src/bhyve/bhyve_parse_command.c -@SRCDIR@/src/bhyve/bhyve_process.c -@SRCDIR@/src/conf/backup_conf.c -@SRCDIR@/src/conf/capabilities.c -@SRCDIR@/src/conf/checkpoint_conf.c -@SRCDIR@/src/conf/cpu_conf.c -@SRCDIR@/src/conf/device_conf.c -@SRCDIR@/src/conf/domain_addr.c -@SRCDIR@/src/conf/domain_capabilities.c -@SRCDIR@/src/conf/domain_conf.c -@SRCDIR@/src/conf/domain_event.c -@SRCDIR@/src/conf/interface_conf.c -@SRCDIR@/src/conf/netdev_bandwidth_conf.c -@SRCDIR@/src/conf/netdev_vlan_conf.c -@SRCDIR@/src/conf/netdev_vport_profile_conf.c -@SRCDIR@/src/conf/network_conf.c -@SRCDIR@/src/conf/networkcommon_conf.c -@SRCDIR@/src/conf/node_device_conf.c -@SRCDIR@/src/conf/node_device_util.c -@SRCDIR@/src/conf/numa_conf.c -@SRCDIR@/src/conf/nwfilter_conf.c -@SRCDIR@/src/conf/nwfilter_params.c -@SRCDIR@/src/conf/object_event.c -@SRCDIR@/src/conf/secret_conf.c -@SRCDIR@/src/conf/snapshot_conf.c -@SRCDIR@/src/conf/storage_adapter_conf.c -@SRCDIR@/src/conf/storage_conf.c -@SRCDIR@/src/conf/virchrdev.c -@SRCDIR@/src/conf/virdomainmomentobjlist.c -@SRCDIR@/src/conf/virdomainobjlist.c -@SRCDIR@/src/conf/virnetworkobj.c -@SRCDIR@/src/conf/virnetworkportdef.c -@SRCDIR@/src/conf/virnodedeviceobj.c -@SRCDIR@/src/conf/virnwfilterbindingdef.c -@SRCDIR@/src/conf/virnwfilterbindingobj.c -@SRCDIR@/src/conf/virnwfilterbindingobjlist.c -@SRCDIR@/src/conf/virnwfilterobj.c -@SRCDIR@/src/conf/virsavecookie.c -@SRCDIR@/src/conf/virsecretobj.c -@SRCDIR@/src/conf/virstorageobj.c -@SRCDIR@/src/cpu/cpu.c -@SRCDIR@/src/cpu/cpu_arm.c -@SRCDIR@/src/cpu/cpu_map.c -@SRCDIR@/src/cpu/cpu_ppc64.c -@SRCDIR@/src/cpu/cpu_s390.c -@SRCDIR@/src/cpu/cpu_x86.c -@SRCDIR@/src/datatypes.c -@SRCDIR@/src/driver.c -@SRCDIR@/src/esx/esx_driver.c -@SRCDIR@/src/esx/esx_network_driver.c -@SRCDIR@/src/esx/esx_storage_backend_iscsi.c -@SRCDIR@/src/esx/esx_storage_backend_vmfs.c -@SRCDIR@/src/esx/esx_storage_driver.c -@SRCDIR@/src/esx/esx_stream.c -@SRCDIR@/src/esx/esx_util.c -@SRCDIR@/src/esx/esx_util.h -@SRCDIR@/src/esx/esx_vi.c -@SRCDIR@/src/esx/esx_vi_methods.c -@SRCDIR@/src/esx/esx_vi_types.c -@SRCDIR@/src/hyperv/hyperv_driver.c -@SRCDIR@/src/hyperv/hyperv_util.c -@SRCDIR@/src/hyperv/hyperv_wmi.c -@SRCDIR@/src/hypervisor/domain_cgroup.c -@SRCDIR@/src/hypervisor/domain_driver.c -@SRCDIR@/src/hypervisor/virclosecallbacks.c -@SRCDIR@/src/hypervisor/virhostdev.c -@SRCDIR@/src/interface/interface_backend_netcf.c -@SRCDIR@/src/interface/interface_backend_udev.c -@SRCDIR@/src/internal.h -@SRCDIR@/src/libvirt-domain-checkpoint.c -@SRCDIR@/src/libvirt-domain-snapshot.c -@SRCDIR@/src/libvirt-domain.c -@SRCDIR@/src/libvirt-host.c -@SRCDIR@/src/libvirt-lxc.c -@SRCDIR@/src/libvirt-network.c -@SRCDIR@/src/libvirt-nodedev.c -@SRCDIR@/src/libvirt-nwfilter.c -@SRCDIR@/src/libvirt-qemu.c -@SRCDIR@/src/libvirt-secret.c -@SRCDIR@/src/libvirt-storage.c -@SRCDIR@/src/libvirt-stream.c -@SRCDIR@/src/libvirt.c -@SRCDIR@/src/libxl/libxl_capabilities.c -@SRCDIR@/src/libxl/libxl_conf.c -@SRCDIR@/src/libxl/libxl_domain.c -@SRCDIR@/src/libxl/libxl_driver.c -@SRCDIR@/src/libxl/libxl_migration.c -@SRCDIR@/src/libxl/xen_common.c -@SRCDIR@/src/libxl/xen_xl.c -@SRCDIR@/src/libxl/xen_xm.c -@SRCDIR@/src/locking/lock_daemon.c -@SRCDIR@/src/locking/lock_daemon_dispatch.c -@SRCDIR@/src/locking/lock_driver_lockd.c -@SRCDIR@/src/locking/lock_driver_sanlock.c -@SRCDIR@/src/locking/lock_manager.c -@SRCDIR@/src/locking/sanlock_helper.c -@SRCDIR@/src/logging/log_daemon.c -@SRCDIR@/src/logging/log_daemon_dispatch.c -@SRCDIR@/src/logging/log_handler.c -@SRCDIR@/src/logging/log_manager.c -@SRCDIR@/src/lxc/lxc_cgroup.c -@SRCDIR@/src/lxc/lxc_conf.c -@SRCDIR@/src/lxc/lxc_container.c -@SRCDIR@/src/lxc/lxc_controller.c -@SRCDIR@/src/lxc/lxc_domain.c -@SRCDIR@/src/lxc/lxc_driver.c -@SRCDIR@/src/lxc/lxc_fuse.c -@SRCDIR@/src/lxc/lxc_hostdev.c -@SRCDIR@/src/lxc/lxc_native.c -@SRCDIR@/src/lxc/lxc_process.c -@SRCDIR@/src/network/bridge_driver.c -@SRCDIR@/src/network/bridge_driver_linux.c -@SRCDIR@/src/network/leaseshelper.c -@SRCDIR@/src/node_device/node_device_driver.c -@SRCDIR@/src/node_device/node_device_hal.c -@SRCDIR@/src/node_device/node_device_udev.c -@SRCDIR@/src/nwfilter/nwfilter_dhcpsnoop.c -@SRCDIR@/src/nwfilter/nwfilter_driver.c -@SRCDIR@/src/nwfilter/nwfilter_ebiptables_driver.c -@SRCDIR@/src/nwfilter/nwfilter_gentech_driver.c -@SRCDIR@/src/nwfilter/nwfilter_learnipaddr.c -@SRCDIR@/src/openvz/openvz_conf.c -@SRCDIR@/src/openvz/openvz_driver.c -@SRCDIR@/src/openvz/openvz_util.c -@SRCDIR@/src/qemu/qemu_agent.c -@SRCDIR@/src/qemu/qemu_alias.c -@SRCDIR@/src/qemu/qemu_backup.c -@SRCDIR@/src/qemu/qemu_block.c -@SRCDIR@/src/qemu/qemu_blockjob.c -@SRCDIR@/src/qemu/qemu_capabilities.c -@SRCDIR@/src/qemu/qemu_cgroup.c -@SRCDIR@/src/qemu/qemu_checkpoint.c -@SRCDIR@/src/qemu/qemu_command.c -@SRCDIR@/src/qemu/qemu_conf.c -@SRCDIR@/src/qemu/qemu_dbus.c -@SRCDIR@/src/qemu/qemu_domain.c -@SRCDIR@/src/qemu/qemu_domainjob.c -@SRCDIR@/src/qemu/qemu_domain_address.c -@SRCDIR@/src/qemu/qemu_driver.c -@SRCDIR@/src/qemu/qemu_extdevice.c -@SRCDIR@/src/qemu/qemu_firmware.c -@SRCDIR@/src/qemu/qemu_hostdev.c -@SRCDIR@/src/qemu/qemu_hotplug.c -@SRCDIR@/src/qemu/qemu_interface.c -@SRCDIR@/src/qemu/qemu_interop_config.c -@SRCDIR@/src/qemu/qemu_migration.c -@SRCDIR@/src/qemu/qemu_migration_cookie.c -@SRCDIR@/src/qemu/qemu_migration_params.c -@SRCDIR@/src/qemu/qemu_monitor.c -@SRCDIR@/src/qemu/qemu_monitor_json.c -@SRCDIR@/src/qemu/qemu_monitor_text.c -@SRCDIR@/src/qemu/qemu_process.c -@SRCDIR@/src/qemu/qemu_qapi.c -@SRCDIR@/src/qemu/qemu_slirp.c -@SRCDIR@/src/qemu/qemu_tpm.c -@SRCDIR@/src/qemu/qemu_validate.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 -@SRCDIR@/src/remote/remote_daemon_stream.c -@SRCDIR@/src/remote/remote_driver.c -@SRCDIR@/src/rpc/virkeepalive.c -@SRCDIR@/src/rpc/virnetclient.c -@SRCDIR@/src/rpc/virnetclientprogram.c -@SRCDIR@/src/rpc/virnetclientstream.c -@SRCDIR@/src/rpc/virnetdaemon.c -@SRCDIR@/src/rpc/virnetlibsshsession.c -@SRCDIR@/src/rpc/virnetmessage.c -@SRCDIR@/src/rpc/virnetsaslcontext.c -@SRCDIR@/src/rpc/virnetserver.c -@SRCDIR@/src/rpc/virnetserverclient.c -@SRCDIR@/src/rpc/virnetserverprogram.c -@SRCDIR@/src/rpc/virnetserverservice.c -@SRCDIR@/src/rpc/virnetsocket.c -@SRCDIR@/src/rpc/virnetsshsession.c -@SRCDIR@/src/rpc/virnettlscontext.c -@SRCDIR@/src/secret/secret_driver.c -@SRCDIR@/src/security/security_apparmor.c -@SRCDIR@/src/security/security_dac.c -@SRCDIR@/src/security/security_driver.c -@SRCDIR@/src/security/security_manager.c -@SRCDIR@/src/security/security_selinux.c -@SRCDIR@/src/security/security_util.c -@SRCDIR@/src/security/virt-aa-helper.c -@SRCDIR@/src/storage/parthelper.c -@SRCDIR@/src/storage/storage_backend.c -@SRCDIR@/src/storage/storage_backend_disk.c -@SRCDIR@/src/storage/storage_backend_fs.c -@SRCDIR@/src/storage/storage_backend_gluster.c -@SRCDIR@/src/storage/storage_backend_iscsi.c -@SRCDIR@/src/storage/storage_backend_iscsi_direct.c -@SRCDIR@/src/storage/storage_backend_logical.c -@SRCDIR@/src/storage/storage_backend_mpath.c -@SRCDIR@/src/storage/storage_backend_rbd.c -@SRCDIR@/src/storage/storage_backend_scsi.c -@SRCDIR@/src/storage/storage_backend_sheepdog.c -@SRCDIR@/src/storage/storage_backend_vstorage.c -@SRCDIR@/src/storage/storage_backend_zfs.c -@SRCDIR@/src/storage/storage_driver.c -@SRCDIR@/src/storage/storage_file_fs.c -@SRCDIR@/src/storage/storage_file_gluster.c -@SRCDIR@/src/storage/storage_util.c -@SRCDIR@/src/test/test_driver.c -@SRCDIR@/src/util/iohelper.c -@SRCDIR@/src/util/viralloc.c -@SRCDIR@/src/util/virarptable.c -@SRCDIR@/src/util/viraudit.c -@SRCDIR@/src/util/virauth.c -@SRCDIR@/src/util/virauthconfig.c -@SRCDIR@/src/util/virbitmap.c -@SRCDIR@/src/util/vircgroup.c -@SRCDIR@/src/util/vircgroupbackend.c -@SRCDIR@/src/util/vircgroupbackend.h -@SRCDIR@/src/util/vircgroupv1.c -@SRCDIR@/src/util/vircgroupv2.c -@SRCDIR@/src/util/vircgroupv2devices.c -@SRCDIR@/src/util/vircommand.c -@SRCDIR@/src/util/virconf.c -@SRCDIR@/src/util/vircrypto.c -@SRCDIR@/src/util/virdaemon.c -@SRCDIR@/src/util/virdbus.c -@SRCDIR@/src/util/virdnsmasq.c -@SRCDIR@/src/util/virerror.c -@SRCDIR@/src/util/virerror.h -@SRCDIR@/src/util/virevent.c -@SRCDIR@/src/util/vireventthread.c -@SRCDIR@/src/util/virfcp.c -@SRCDIR@/src/util/virfdstream.c -@SRCDIR@/src/util/virfile.c -@SRCDIR@/src/util/virfilecache.c -@SRCDIR@/src/util/virfirewall.c -@SRCDIR@/src/util/virfirewalld.c -@SRCDIR@/src/util/virfirmware.c -@SRCDIR@/src/util/virhash.c -@SRCDIR@/src/util/virhook.c -@SRCDIR@/src/util/virhostcpu.c -@SRCDIR@/src/util/virhostmem.c -@SRCDIR@/src/util/virhostuptime.c -@SRCDIR@/src/util/viridentity.c -@SRCDIR@/src/util/virinitctl.c -@SRCDIR@/src/util/viriptables.c -@SRCDIR@/src/util/viriscsi.c -@SRCDIR@/src/util/virjson.c -@SRCDIR@/src/util/virlease.c -@SRCDIR@/src/util/virlockspace.c -@SRCDIR@/src/util/virlog.c -@SRCDIR@/src/util/virmacmap.c -@SRCDIR@/src/util/virmdev.c -@SRCDIR@/src/util/virmodule.c -@SRCDIR@/src/util/virnetdev.c -@SRCDIR@/src/util/virnetdevbandwidth.c -@SRCDIR@/src/util/virnetdevbridge.c -@SRCDIR@/src/util/virnetdevip.c -@SRCDIR@/src/util/virnetdevmacvlan.c -@SRCDIR@/src/util/virnetdevmidonet.c -@SRCDIR@/src/util/virnetdevopenvswitch.c -@SRCDIR@/src/util/virnetdevtap.c -@SRCDIR@/src/util/virnetdevveth.c -@SRCDIR@/src/util/virnetdevvportprofile.c -@SRCDIR@/src/util/virnetlink.c -@SRCDIR@/src/util/virnodesuspend.c -@SRCDIR@/src/util/virnuma.c -@SRCDIR@/src/util/virnvme.c -@SRCDIR@/src/util/virobject.c -@SRCDIR@/src/util/virpci.c -@SRCDIR@/src/util/virperf.c -@SRCDIR@/src/util/virpidfile.c -@SRCDIR@/src/util/virpolkit.c -@SRCDIR@/src/util/virportallocator.c -@SRCDIR@/src/util/virprocess.c -@SRCDIR@/src/util/virqemu.c -@SRCDIR@/src/util/virrandom.c -@SRCDIR@/src/util/virresctrl.c -@SRCDIR@/src/util/virrotatingfile.c -@SRCDIR@/src/util/virscsi.c -@SRCDIR@/src/util/virscsihost.c -@SRCDIR@/src/util/virscsivhost.c -@SRCDIR@/src/util/virsecret.c -@SRCDIR@/src/util/virsocketaddr.c -@SRCDIR@/src/util/virstorageencryption.c -@SRCDIR@/src/util/virstoragefile.c -@SRCDIR@/src/util/virstoragefilebackend.c -@SRCDIR@/src/util/virstring.c -@SRCDIR@/src/util/virsysinfo.c -@SRCDIR@/src/util/virsystemd.c -@SRCDIR@/src/util/virthreadjob.c -@SRCDIR@/src/util/virthreadpool.c -@SRCDIR@/src/util/virtime.c -@SRCDIR@/src/util/virtpm.c -@SRCDIR@/src/util/virtypedparam-public.c -@SRCDIR@/src/util/virtypedparam.c -@SRCDIR@/src/util/viruri.c -@SRCDIR@/src/util/virusb.c -@SRCDIR@/src/util/virutil.c -@SRCDIR@/src/util/virvhba.c -@SRCDIR@/src/util/virvsock.c -@SRCDIR@/src/util/virxml.c -@SRCDIR@/src/vbox/vbox_XPCOMCGlue.c -@SRCDIR@/src/vbox/vbox_common.c -@SRCDIR@/src/vbox/vbox_driver.c -@SRCDIR@/src/vbox/vbox_network.c -@SRCDIR@/src/vbox/vbox_snapshot_conf.c -@SRCDIR@/src/vbox/vbox_storage.c -@SRCDIR@/src/vbox/vbox_tmpl.c -@SRCDIR@/src/vmware/vmware_conf.c -@SRCDIR@/src/vmware/vmware_driver.c -@SRCDIR@/src/vmx/vmx.c -@SRCDIR@/src/vz/vz_driver.c -@SRCDIR@/src/vz/vz_sdk.c -@SRCDIR@/src/vz/vz_utils.c -@SRCDIR@/src/vz/vz_utils.h -@SRCDIR@/tests/virpolkittest.c -@SRCDIR@/tools/libvirt-guests.sh.in -@SRCDIR@/tools/virsh-backup.c -@SRCDIR@/tools/virsh-checkpoint.c -@SRCDIR@/tools/virsh-completer-host.c -@SRCDIR@/tools/virsh-console.c -@SRCDIR@/tools/virsh-domain-monitor.c -@SRCDIR@/tools/virsh-domain.c -@SRCDIR@/tools/virsh-edit.c -@SRCDIR@/tools/virsh-host.c -@SRCDIR@/tools/virsh-interface.c -@SRCDIR@/tools/virsh-network.c -@SRCDIR@/tools/virsh-nodedev.c -@SRCDIR@/tools/virsh-nwfilter.c -@SRCDIR@/tools/virsh-pool.c -@SRCDIR@/tools/virsh-secret.c -@SRCDIR@/tools/virsh-snapshot.c -@SRCDIR@/tools/virsh-util.c -@SRCDIR@/tools/virsh-volume.c -@SRCDIR@/tools/virsh.c -@SRCDIR@/tools/virsh.h -@SRCDIR@/tools/virt-admin.c -@SRCDIR@/tools/virt-host-validate-bhyve.c -@SRCDIR@/tools/virt-host-validate-common.c -@SRCDIR@/tools/virt-host-validate-lxc.c -@SRCDIR@/tools/virt-host-validate-qemu.c -@SRCDIR@/tools/virt-host-validate.c -@SRCDIR@/tools/virt-login-shell-helper.c -@SRCDIR@/tools/vsh-table.c -@SRCDIR@/tools/vsh.c -@SRCDIR@/tools/vsh.h +@BUILDDIR@src/access/viraccessapicheck.c +@BUILDDIR@src/access/viraccessapichecklxc.c +@BUILDDIR@src/access/viraccessapicheckqemu.c +@BUILDDIR@src/admin/admin_client.h +@BUILDDIR@src/admin/admin_server_dispatch_stubs.h +@BUILDDIR@src/remote/remote_client_bodies.h +@BUILDDIR@src/remote/remote_daemon_dispatch_stubs.h +@SRCDIR@src/access/viraccessdriverpolkit.c +@SRCDIR@src/access/viraccessmanager.c +@SRCDIR@src/admin/admin_server.c +@SRCDIR@src/admin/admin_server_dispatch.c +@SRCDIR@src/admin/libvirt-admin.c +@SRCDIR@src/bhyve/bhyve_capabilities.c +@SRCDIR@src/bhyve/bhyve_command.c +@SRCDIR@src/bhyve/bhyve_device.c +@SRCDIR@src/bhyve/bhyve_domain.c +@SRCDIR@src/bhyve/bhyve_driver.c +@SRCDIR@src/bhyve/bhyve_monitor.c +@SRCDIR@src/bhyve/bhyve_parse_command.c +@SRCDIR@src/bhyve/bhyve_process.c +@SRCDIR@src/conf/backup_conf.c +@SRCDIR@src/conf/capabilities.c +@SRCDIR@src/conf/checkpoint_conf.c +@SRCDIR@src/conf/cpu_conf.c +@SRCDIR@src/conf/device_conf.c +@SRCDIR@src/conf/domain_addr.c +@SRCDIR@src/conf/domain_capabilities.c +@SRCDIR@src/conf/domain_conf.c +@SRCDIR@src/conf/domain_event.c +@SRCDIR@src/conf/interface_conf.c +@SRCDIR@src/conf/netdev_bandwidth_conf.c +@SRCDIR@src/conf/netdev_vlan_conf.c +@SRCDIR@src/conf/netdev_vport_profile_conf.c +@SRCDIR@src/conf/network_conf.c +@SRCDIR@src/conf/networkcommon_conf.c +@SRCDIR@src/conf/node_device_conf.c +@SRCDIR@src/conf/node_device_util.c +@SRCDIR@src/conf/numa_conf.c +@SRCDIR@src/conf/nwfilter_conf.c +@SRCDIR@src/conf/nwfilter_params.c +@SRCDIR@src/conf/object_event.c +@SRCDIR@src/conf/secret_conf.c +@SRCDIR@src/conf/snapshot_conf.c +@SRCDIR@src/conf/storage_adapter_conf.c +@SRCDIR@src/conf/storage_conf.c +@SRCDIR@src/conf/virchrdev.c +@SRCDIR@src/conf/virdomainmomentobjlist.c +@SRCDIR@src/conf/virdomainobjlist.c +@SRCDIR@src/conf/virnetworkobj.c +@SRCDIR@src/conf/virnetworkportdef.c +@SRCDIR@src/conf/virnodedeviceobj.c +@SRCDIR@src/conf/virnwfilterbindingdef.c +@SRCDIR@src/conf/virnwfilterbindingobj.c +@SRCDIR@src/conf/virnwfilterbindingobjlist.c +@SRCDIR@src/conf/virnwfilterobj.c +@SRCDIR@src/conf/virsavecookie.c +@SRCDIR@src/conf/virsecretobj.c +@SRCDIR@src/conf/virstorageobj.c +@SRCDIR@src/cpu/cpu.c +@SRCDIR@src/cpu/cpu_arm.c +@SRCDIR@src/cpu/cpu_map.c +@SRCDIR@src/cpu/cpu_ppc64.c +@SRCDIR@src/cpu/cpu_s390.c +@SRCDIR@src/cpu/cpu_x86.c +@SRCDIR@src/datatypes.c +@SRCDIR@src/driver.c +@SRCDIR@src/esx/esx_driver.c +@SRCDIR@src/esx/esx_network_driver.c +@SRCDIR@src/esx/esx_storage_backend_iscsi.c +@SRCDIR@src/esx/esx_storage_backend_vmfs.c +@SRCDIR@src/esx/esx_storage_driver.c +@SRCDIR@src/esx/esx_stream.c +@SRCDIR@src/esx/esx_util.c +@SRCDIR@src/esx/esx_util.h +@SRCDIR@src/esx/esx_vi.c +@SRCDIR@src/esx/esx_vi_methods.c +@SRCDIR@src/esx/esx_vi_types.c +@SRCDIR@src/hyperv/hyperv_driver.c +@SRCDIR@src/hyperv/hyperv_util.c +@SRCDIR@src/hyperv/hyperv_wmi.c +@SRCDIR@src/hypervisor/domain_cgroup.c +@SRCDIR@src/hypervisor/domain_driver.c +@SRCDIR@src/hypervisor/virclosecallbacks.c +@SRCDIR@src/hypervisor/virhostdev.c +@SRCDIR@src/interface/interface_backend_netcf.c +@SRCDIR@src/interface/interface_backend_udev.c +@SRCDIR@src/internal.h +@SRCDIR@src/libvirt-domain-checkpoint.c +@SRCDIR@src/libvirt-domain-snapshot.c +@SRCDIR@src/libvirt-domain.c +@SRCDIR@src/libvirt-host.c +@SRCDIR@src/libvirt-lxc.c +@SRCDIR@src/libvirt-network.c +@SRCDIR@src/libvirt-nodedev.c +@SRCDIR@src/libvirt-nwfilter.c +@SRCDIR@src/libvirt-qemu.c +@SRCDIR@src/libvirt-secret.c +@SRCDIR@src/libvirt-storage.c +@SRCDIR@src/libvirt-stream.c +@SRCDIR@src/libvirt.c +@SRCDIR@src/libxl/libxl_capabilities.c +@SRCDIR@src/libxl/libxl_conf.c +@SRCDIR@src/libxl/libxl_domain.c +@SRCDIR@src/libxl/libxl_driver.c +@SRCDIR@src/libxl/libxl_migration.c +@SRCDIR@src/libxl/xen_common.c +@SRCDIR@src/libxl/xen_xl.c +@SRCDIR@src/libxl/xen_xm.c +@SRCDIR@src/locking/lock_daemon.c +@SRCDIR@src/locking/lock_daemon_dispatch.c +@SRCDIR@src/locking/lock_driver_lockd.c +@SRCDIR@src/locking/lock_driver_sanlock.c +@SRCDIR@src/locking/lock_manager.c +@SRCDIR@src/locking/sanlock_helper.c +@SRCDIR@src/logging/log_daemon.c +@SRCDIR@src/logging/log_daemon_dispatch.c +@SRCDIR@src/logging/log_handler.c +@SRCDIR@src/logging/log_manager.c +@SRCDIR@src/lxc/lxc_cgroup.c +@SRCDIR@src/lxc/lxc_conf.c +@SRCDIR@src/lxc/lxc_container.c +@SRCDIR@src/lxc/lxc_controller.c +@SRCDIR@src/lxc/lxc_domain.c +@SRCDIR@src/lxc/lxc_driver.c +@SRCDIR@src/lxc/lxc_fuse.c +@SRCDIR@src/lxc/lxc_hostdev.c +@SRCDIR@src/lxc/lxc_native.c +@SRCDIR@src/lxc/lxc_process.c +@SRCDIR@src/network/bridge_driver.c +@SRCDIR@src/network/bridge_driver_linux.c +@SRCDIR@src/network/leaseshelper.c +@SRCDIR@src/node_device/node_device_driver.c +@SRCDIR@src/node_device/node_device_hal.c +@SRCDIR@src/node_device/node_device_udev.c +@SRCDIR@src/nwfilter/nwfilter_dhcpsnoop.c +@SRCDIR@src/nwfilter/nwfilter_driver.c +@SRCDIR@src/nwfilter/nwfilter_ebiptables_driver.c +@SRCDIR@src/nwfilter/nwfilter_gentech_driver.c +@SRCDIR@src/nwfilter/nwfilter_learnipaddr.c +@SRCDIR@src/openvz/openvz_conf.c +@SRCDIR@src/openvz/openvz_driver.c +@SRCDIR@src/openvz/openvz_util.c +@SRCDIR@src/qemu/qemu_agent.c +@SRCDIR@src/qemu/qemu_alias.c +@SRCDIR@src/qemu/qemu_backup.c +@SRCDIR@src/qemu/qemu_block.c +@SRCDIR@src/qemu/qemu_blockjob.c +@SRCDIR@src/qemu/qemu_capabilities.c +@SRCDIR@src/qemu/qemu_cgroup.c +@SRCDIR@src/qemu/qemu_checkpoint.c +@SRCDIR@src/qemu/qemu_command.c +@SRCDIR@src/qemu/qemu_conf.c +@SRCDIR@src/qemu/qemu_dbus.c +@SRCDIR@src/qemu/qemu_domain.c +@SRCDIR@src/qemu/qemu_domain_address.c +@SRCDIR@src/qemu/qemu_domainjob.c +@SRCDIR@src/qemu/qemu_driver.c +@SRCDIR@src/qemu/qemu_extdevice.c +@SRCDIR@src/qemu/qemu_firmware.c +@SRCDIR@src/qemu/qemu_hostdev.c +@SRCDIR@src/qemu/qemu_hotplug.c +@SRCDIR@src/qemu/qemu_interface.c +@SRCDIR@src/qemu/qemu_interop_config.c +@SRCDIR@src/qemu/qemu_migration.c +@SRCDIR@src/qemu/qemu_migration_cookie.c +@SRCDIR@src/qemu/qemu_migration_params.c +@SRCDIR@src/qemu/qemu_monitor.c +@SRCDIR@src/qemu/qemu_monitor_json.c +@SRCDIR@src/qemu/qemu_monitor_text.c +@SRCDIR@src/qemu/qemu_process.c +@SRCDIR@src/qemu/qemu_qapi.c +@SRCDIR@src/qemu/qemu_slirp.c +@SRCDIR@src/qemu/qemu_tpm.c +@SRCDIR@src/qemu/qemu_validate.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 +@SRCDIR@src/remote/remote_daemon_stream.c +@SRCDIR@src/remote/remote_driver.c +@SRCDIR@src/rpc/virkeepalive.c +@SRCDIR@src/rpc/virnetclient.c +@SRCDIR@src/rpc/virnetclientprogram.c +@SRCDIR@src/rpc/virnetclientstream.c +@SRCDIR@src/rpc/virnetdaemon.c +@SRCDIR@src/rpc/virnetlibsshsession.c +@SRCDIR@src/rpc/virnetmessage.c +@SRCDIR@src/rpc/virnetsaslcontext.c +@SRCDIR@src/rpc/virnetserver.c +@SRCDIR@src/rpc/virnetserverclient.c +@SRCDIR@src/rpc/virnetserverprogram.c +@SRCDIR@src/rpc/virnetserverservice.c +@SRCDIR@src/rpc/virnetsocket.c +@SRCDIR@src/rpc/virnetsshsession.c +@SRCDIR@src/rpc/virnettlscontext.c +@SRCDIR@src/secret/secret_driver.c +@SRCDIR@src/security/security_apparmor.c +@SRCDIR@src/security/security_dac.c +@SRCDIR@src/security/security_driver.c +@SRCDIR@src/security/security_manager.c +@SRCDIR@src/security/security_selinux.c +@SRCDIR@src/security/security_util.c +@SRCDIR@src/security/virt-aa-helper.c +@SRCDIR@src/storage/parthelper.c +@SRCDIR@src/storage/storage_backend.c +@SRCDIR@src/storage/storage_backend_disk.c +@SRCDIR@src/storage/storage_backend_fs.c +@SRCDIR@src/storage/storage_backend_gluster.c +@SRCDIR@src/storage/storage_backend_iscsi.c +@SRCDIR@src/storage/storage_backend_iscsi_direct.c +@SRCDIR@src/storage/storage_backend_logical.c +@SRCDIR@src/storage/storage_backend_mpath.c +@SRCDIR@src/storage/storage_backend_rbd.c +@SRCDIR@src/storage/storage_backend_scsi.c +@SRCDIR@src/storage/storage_backend_sheepdog.c +@SRCDIR@src/storage/storage_backend_vstorage.c +@SRCDIR@src/storage/storage_backend_zfs.c +@SRCDIR@src/storage/storage_driver.c +@SRCDIR@src/storage/storage_file_fs.c +@SRCDIR@src/storage/storage_file_gluster.c +@SRCDIR@src/storage/storage_util.c +@SRCDIR@src/test/test_driver.c +@SRCDIR@src/util/iohelper.c +@SRCDIR@src/util/viralloc.c +@SRCDIR@src/util/virarptable.c +@SRCDIR@src/util/viraudit.c +@SRCDIR@src/util/virauth.c +@SRCDIR@src/util/virauthconfig.c +@SRCDIR@src/util/virbitmap.c +@SRCDIR@src/util/vircgroup.c +@SRCDIR@src/util/vircgroupbackend.c +@SRCDIR@src/util/vircgroupbackend.h +@SRCDIR@src/util/vircgroupv1.c +@SRCDIR@src/util/vircgroupv2.c +@SRCDIR@src/util/vircgroupv2devices.c +@SRCDIR@src/util/vircommand.c +@SRCDIR@src/util/virconf.c +@SRCDIR@src/util/vircrypto.c +@SRCDIR@src/util/virdaemon.c +@SRCDIR@src/util/virdbus.c +@SRCDIR@src/util/virdevmapper.c +@SRCDIR@src/util/virdnsmasq.c +@SRCDIR@src/util/virerror.c +@SRCDIR@src/util/virerror.h +@SRCDIR@src/util/virevent.c +@SRCDIR@src/util/vireventthread.c +@SRCDIR@src/util/virfcp.c +@SRCDIR@src/util/virfdstream.c +@SRCDIR@src/util/virfile.c +@SRCDIR@src/util/virfilecache.c +@SRCDIR@src/util/virfirewall.c +@SRCDIR@src/util/virfirewalld.c +@SRCDIR@src/util/virfirmware.c +@SRCDIR@src/util/virhash.c +@SRCDIR@src/util/virhook.c +@SRCDIR@src/util/virhostcpu.c +@SRCDIR@src/util/virhostmem.c +@SRCDIR@src/util/virhostuptime.c +@SRCDIR@src/util/viridentity.c +@SRCDIR@src/util/virinitctl.c +@SRCDIR@src/util/viriptables.c +@SRCDIR@src/util/viriscsi.c +@SRCDIR@src/util/virjson.c +@SRCDIR@src/util/virlease.c +@SRCDIR@src/util/virlockspace.c +@SRCDIR@src/util/virlog.c +@SRCDIR@src/util/virmacmap.c +@SRCDIR@src/util/virmdev.c +@SRCDIR@src/util/virmodule.c +@SRCDIR@src/util/virnetdev.c +@SRCDIR@src/util/virnetdevbandwidth.c +@SRCDIR@src/util/virnetdevbridge.c +@SRCDIR@src/util/virnetdevip.c +@SRCDIR@src/util/virnetdevmacvlan.c +@SRCDIR@src/util/virnetdevmidonet.c +@SRCDIR@src/util/virnetdevopenvswitch.c +@SRCDIR@src/util/virnetdevtap.c +@SRCDIR@src/util/virnetdevveth.c +@SRCDIR@src/util/virnetdevvportprofile.c +@SRCDIR@src/util/virnetlink.c +@SRCDIR@src/util/virnodesuspend.c +@SRCDIR@src/util/virnuma.c +@SRCDIR@src/util/virnvme.c +@SRCDIR@src/util/virobject.c +@SRCDIR@src/util/virpci.c +@SRCDIR@src/util/virperf.c +@SRCDIR@src/util/virpidfile.c +@SRCDIR@src/util/virpolkit.c +@SRCDIR@src/util/virportallocator.c +@SRCDIR@src/util/virprocess.c +@SRCDIR@src/util/virqemu.c +@SRCDIR@src/util/virrandom.c +@SRCDIR@src/util/virresctrl.c +@SRCDIR@src/util/virrotatingfile.c +@SRCDIR@src/util/virscsi.c +@SRCDIR@src/util/virscsihost.c +@SRCDIR@src/util/virscsivhost.c +@SRCDIR@src/util/virsecret.c +@SRCDIR@src/util/virsocketaddr.c +@SRCDIR@src/util/virstorageencryption.c +@SRCDIR@src/util/virstoragefile.c +@SRCDIR@src/util/virstoragefilebackend.c +@SRCDIR@src/util/virstring.c +@SRCDIR@src/util/virsysinfo.c +@SRCDIR@src/util/virsystemd.c +@SRCDIR@src/util/virthreadjob.c +@SRCDIR@src/util/virthreadpool.c +@SRCDIR@src/util/virtime.c +@SRCDIR@src/util/virtpm.c +@SRCDIR@src/util/virtypedparam-public.c +@SRCDIR@src/util/virtypedparam.c +@SRCDIR@src/util/viruri.c +@SRCDIR@src/util/virusb.c +@SRCDIR@src/util/virutil.c +@SRCDIR@src/util/virvhba.c +@SRCDIR@src/util/virvsock.c +@SRCDIR@src/util/virxml.c +@SRCDIR@src/vbox/vbox_XPCOMCGlue.c +@SRCDIR@src/vbox/vbox_common.c +@SRCDIR@src/vbox/vbox_driver.c +@SRCDIR@src/vbox/vbox_network.c +@SRCDIR@src/vbox/vbox_snapshot_conf.c +@SRCDIR@src/vbox/vbox_storage.c +@SRCDIR@src/vbox/vbox_tmpl.c +@SRCDIR@src/vmware/vmware_conf.c +@SRCDIR@src/vmware/vmware_driver.c +@SRCDIR@src/vmx/vmx.c +@SRCDIR@src/vz/vz_driver.c +@SRCDIR@src/vz/vz_sdk.c +@SRCDIR@src/vz/vz_utils.c +@SRCDIR@src/vz/vz_utils.h +@SRCDIR@tests/virpolkittest.c +@SRCDIR@tools/libvirt-guests.sh.in +@SRCDIR@tools/virsh-backup.c +@SRCDIR@tools/virsh-checkpoint.c +@SRCDIR@tools/virsh-completer-host.c +@SRCDIR@tools/virsh-console.c +@SRCDIR@tools/virsh-domain-monitor.c +@SRCDIR@tools/virsh-domain.c +@SRCDIR@tools/virsh-edit.c +@SRCDIR@tools/virsh-host.c +@SRCDIR@tools/virsh-interface.c +@SRCDIR@tools/virsh-network.c +@SRCDIR@tools/virsh-nodedev.c +@SRCDIR@tools/virsh-nwfilter.c +@SRCDIR@tools/virsh-pool.c +@SRCDIR@tools/virsh-secret.c +@SRCDIR@tools/virsh-snapshot.c +@SRCDIR@tools/virsh-util.c +@SRCDIR@tools/virsh-volume.c +@SRCDIR@tools/virsh.c +@SRCDIR@tools/virsh.h +@SRCDIR@tools/virt-admin.c +@SRCDIR@tools/virt-host-validate-bhyve.c +@SRCDIR@tools/virt-host-validate-common.c +@SRCDIR@tools/virt-host-validate-lxc.c +@SRCDIR@tools/virt-host-validate-qemu.c +@SRCDIR@tools/virt-host-validate.c +@SRCDIR@tools/virt-login-shell-helper.c +@SRCDIR@tools/vsh-table.c +@SRCDIR@tools/vsh.c +@SRCDIR@tools/vsh.h diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index 914bf640ca..e88da02341 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -87,7 +87,7 @@ qemuSetupImagePathCgroup(virDomainObjPtr vm, } if (virDevMapperGetTargets(path, &targetPaths) < 0 && - errno != ENOSYS && errno != EBADF) { + errno != ENOSYS) { virReportSystemError(errno, _("Unable to get devmapper targets for %s"), path); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index c5b8d91f9a..088d711ae3 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -10338,7 +10338,7 @@ qemuDomainSetupDisk(virQEMUDriverConfigPtr cfg G_GNUC_UNUSED, return -1; if (virDevMapperGetTargets(next->path, &targetPaths) < 0 && - errno != ENOSYS && errno != EBADF) { + errno != ENOSYS) { virReportSystemError(errno, _("Unable to get devmapper targets for %s"), next->path); @@ -11402,7 +11402,7 @@ qemuDomainNamespaceSetupDisk(virDomainObjPtr vm, tmpPath = g_strdup(next->path); if (virDevMapperGetTargets(next->path, &targetPaths) < 0 && - errno != ENOSYS && errno != EBADF) { + errno != ENOSYS) { virReportSystemError(errno, _("Unable to get devmapper targets for %s"), next->path); diff --git a/src/util/virdevmapper.c b/src/util/virdevmapper.c index 40a82285f9..a471504176 100644 --- a/src/util/virdevmapper.c +++ b/src/util/virdevmapper.c @@ -20,38 +20,67 @@ #include +#include "virdevmapper.h" +#include "internal.h" + #ifdef __linux__ # include -#endif +# include +# include +# include +# include +# include -#ifdef WITH_DEVMAPPER -# include -#endif +# include "virthread.h" +# include "viralloc.h" +# include "virstring.h" +# include "virfile.h" + +# define VIR_FROM_THIS VIR_FROM_STORAGE + +# define PROC_DEVICES "/proc/devices" +# define DM_NAME "device-mapper" +# define DEV_DM_DIR "/dev/" DM_DIR +# define CONTROL_PATH DEV_DM_DIR "/" DM_CONTROL_NODE +# define BUF_SIZE (16 * 1024) + +G_STATIC_ASSERT(BUF_SIZE > sizeof(struct dm_ioctl)); + +static unsigned int virDMMajor; -#include "virdevmapper.h" -#include "internal.h" -#include "virthread.h" -#include "viralloc.h" -#include "virstring.h" - -#ifdef WITH_DEVMAPPER -static void -virDevMapperDummyLogger(int level G_GNUC_UNUSED, - const char *file G_GNUC_UNUSED, - int line G_GNUC_UNUSED, - int dm_errno G_GNUC_UNUSED, - const char *fmt G_GNUC_UNUSED, - ...) -{ - return; -} static int virDevMapperOnceInit(void) { - /* Ideally, we would not need this. But libdevmapper prints - * error messages to stderr by default. Sad but true. */ - dm_log_with_errno_init(virDevMapperDummyLogger); + g_autofree char *buf = NULL; + VIR_AUTOSTRINGLIST lines = NULL; + size_t i; + + if (virFileReadAll(PROC_DEVICES, BUF_SIZE, &buf) < 0) + return -1; + + lines = virStringSplit(buf, "\n", 0); + if (!lines) + return -1; + + for (i = 0; lines[i]; i++) { + g_autofree char *dev = NULL; + unsigned int maj; + + if (sscanf(lines[i], "%u %ms\n", &maj, &dev) == 2 && + STREQ(dev, DM_NAME)) { + virDMMajor = maj; + break; + } + } + + if (!lines[i]) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to find major for %s"), + DM_NAME); + return -1; + } + return 0; } @@ -59,104 +88,190 @@ virDevMapperOnceInit(void) VIR_ONCE_GLOBAL_INIT(virDevMapper); +static void * +virDMIoctl(int controlFD, int cmd, struct dm_ioctl *dm, char **buf) +{ + size_t bufsize = BUF_SIZE; + + reread: + *buf = g_new0(char, bufsize); + + dm->version[0] = DM_VERSION_MAJOR; + dm->version[1] = 0; + dm->version[2] = 0; + dm->data_size = bufsize; + dm->data_start = sizeof(struct dm_ioctl); + + memcpy(*buf, dm, sizeof(struct dm_ioctl)); + + if (ioctl(controlFD, cmd, *buf) < 0) { + VIR_FREE(*buf); + return NULL; + } + + memcpy(dm, *buf, sizeof(struct dm_ioctl)); + + if (dm->flags & DM_BUFFER_FULL_FLAG) { + bufsize += BUF_SIZE; + VIR_FREE(*buf); + goto reread; + } + + return *buf + dm->data_start; +} + + static int -virDevMapperGetTargetsImpl(const char *path, +virDMOpen(void) +{ + VIR_AUTOCLOSE controlFD = -1; + struct dm_ioctl dm; + g_autofree char *tmp = NULL; + int ret; + + memset(&dm, 0, sizeof(dm)); + + if ((controlFD = open(CONTROL_PATH, O_RDWR)) < 0) + return -1; + + if (!virDMIoctl(controlFD, DM_VERSION, &dm, &tmp)) { + virReportSystemError(errno, "%s", + _("Unable to get device-mapper version")); + return -1; + } + + if (dm.version[0] != DM_VERSION_MAJOR) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("Unsupported device-mapper version. Expected %d got %d"), + DM_VERSION_MAJOR, dm.version[0]); + return -1; + } + + ret = controlFD; + controlFD = -1; + return ret; +} + + +static char * +virDMSanitizepath(const char *path) +{ + g_autofree char *dmDirPath = NULL; + struct dirent *ent = NULL; + struct stat sb[2]; + DIR *dh = NULL; + const char *p; + char *ret = NULL; + int rc; + + /* If a path is NOT provided then assume it's DM name */ + p = strrchr(path, '/'); + + if (!p) + return g_strdup(path); + else + p++; + + /* It's a path. Check if the last component is DM name */ + if (stat(path, &sb[0]) < 0) { + virReportError(errno, + _("Unable to stat %p"), + path); + return NULL; + } + + dmDirPath = g_strdup_printf(DEV_DM_DIR "/%s", p); + + if (stat(dmDirPath, &sb[1]) == 0 && + sb[0].st_rdev == sb[1].st_rdev) { + return g_strdup(p); + } + + /* The last component of @path wasn't DM name. Let's check if + * there's a device under /dev/mapper/ with the same rdev. */ + if (virDirOpen(&dh, DEV_DM_DIR) < 0) + return NULL; + + while ((rc = virDirRead(dh, &ent, DEV_DM_DIR)) > 0) { + g_autofree char *tmp = g_strdup_printf(DEV_DM_DIR "/%s", ent->d_name); + + if (stat(tmp, &sb[1]) == 0 && + sb[0].st_rdev == sb[0].st_rdev) { + ret = g_steal_pointer(&tmp); + break; + } + } + + virDirClose(&dh); + return ret; +} + + +static int +virDevMapperGetTargetsImpl(int controlFD, + const char *path, char ***devPaths_ret, unsigned int ttl) { - struct dm_task *dmt = NULL; - struct dm_deps *deps; - struct dm_info info; - char **devPaths = NULL; - char **recursiveDevPaths = NULL; + g_autofree char *sanitizedPath = NULL; + g_autofree char *buf = NULL; + struct dm_ioctl dm; + struct dm_target_deps *deps = NULL; + VIR_AUTOSTRINGLIST devPaths = NULL; size_t i; - int ret = -1; + memset(&dm, 0, sizeof(dm)); *devPaths_ret = NULL; - if (virDevMapperInitialize() < 0) - return ret; - if (ttl == 0) { errno = ELOOP; - return ret; + return -1; } if (!virIsDevMapperDevice(path)) return 0; - if (!(dmt = dm_task_create(DM_DEVICE_DEPS))) { - if (errno == ENOENT || errno == ENODEV) { - /* It's okay. Kernel is probably built without - * devmapper support. */ - ret = 0; - } - return ret; - } - - if (!dm_task_set_name(dmt, path)) { - if (errno == ENOENT) { - /* It's okay, @path is not managed by devmapper => - * not a devmapper device. */ - ret = 0; - } - goto cleanup; - } - - dm_task_no_open_count(dmt); + if (!(sanitizedPath = virDMSanitizepath(path))) + return 0; - if (!dm_task_run(dmt)) { - if (errno == ENXIO) { - /* If @path = "/dev/mapper/control" ENXIO is returned. */ - ret = 0; - } - goto cleanup; + if (virStrncpy(dm.name, sanitizedPath, -1, DM_TABLE_DEPS) < 0) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("Resolved device mapper name too long")); + return -1; } - if (!dm_task_get_info(dmt, &info)) - goto cleanup; + deps = virDMIoctl(controlFD, DM_TABLE_DEPS, &dm, &buf); + if (!deps) { + if (errno == ENXIO) + return 0; - if (!info.exists) { - ret = 0; - goto cleanup; + virReportSystemError(errno, + _("Unable to query dependencies for %s"), + path); + return -1; } - if (!(deps = dm_task_get_deps(dmt))) - goto cleanup; - if (VIR_ALLOC_N_QUIET(devPaths, deps->count + 1) < 0) - goto cleanup; + return -1; for (i = 0; i < deps->count; i++) { devPaths[i] = g_strdup_printf("/dev/block/%u:%u", - major(deps->device[i]), - minor(deps->device[i])); + major(deps->dev[i]), + minor(deps->dev[i])); } - recursiveDevPaths = NULL; for (i = 0; i < deps->count; i++) { - char **tmpPaths; + VIR_AUTOSTRINGLIST tmpPaths = NULL; - if (virDevMapperGetTargetsImpl(devPaths[i], &tmpPaths, ttl - 1) < 0) - goto cleanup; + if (virDevMapperGetTargetsImpl(controlFD, devPaths[i], &tmpPaths, ttl - 1) < 0) + return -1; - if (tmpPaths && - virStringListMerge(&recursiveDevPaths, &tmpPaths) < 0) { - virStringListFree(tmpPaths); - goto cleanup; - } + if (virStringListMerge(&devPaths, &tmpPaths) < 0) + return -1; } - if (virStringListMerge(&devPaths, &recursiveDevPaths) < 0) - goto cleanup; - *devPaths_ret = g_steal_pointer(&devPaths); - ret = 0; - cleanup: - virStringListFree(recursiveDevPaths); - virStringListFree(devPaths); - dm_task_destroy(dmt); - return ret; + return 0; } @@ -175,9 +290,6 @@ virDevMapperGetTargetsImpl(const char *path, * If @path consists of yet another devmapper targets these are * consulted recursively. * - * If we don't have permissions to talk to kernel, -1 is returned - * and errno is set to EBADF. - * * Returns 0 on success, * -1 otherwise (with errno set, no libvirt error is * reported) @@ -186,46 +298,53 @@ int virDevMapperGetTargets(const char *path, char ***devPaths) { + VIR_AUTOCLOSE controlFD = -1; const unsigned int ttl = 32; /* Arbitrary limit on recursion level. A devmapper target can * consist of devices or yet another targets. If that's the * case, we have to stop recursion somewhere. */ - return virDevMapperGetTargetsImpl(path, devPaths, ttl); -} + if (virDevMapperInitialize() < 0) + return -1; -#else /* ! WITH_DEVMAPPER */ + if ((controlFD = virDMOpen()) < 0) + return -1; -int -virDevMapperGetTargets(const char *path G_GNUC_UNUSED, - char ***devPaths G_GNUC_UNUSED) -{ - errno = ENOSYS; - return -1; + return virDevMapperGetTargetsImpl(controlFD, path, devPaths, ttl); } -#endif /* ! WITH_DEVMAPPER */ -#if WITH_DEVMAPPER bool virIsDevMapperDevice(const char *dev_name) { struct stat buf; + if (virDevMapperInitialize() < 0) + return false; + if (!stat(dev_name, &buf) && S_ISBLK(buf.st_mode) && - dm_is_dm_major(major(buf.st_rdev))) - return true; + major(buf.st_rdev) == virDMMajor) + return true; return false; } -#else /* ! WITH_DEVMAPPER */ +#else /* !defined(__linux__) */ + +int +virDevMapperGetTargets(const char *path G_GNUC_UNUSED, + char ***devPaths G_GNUC_UNUSED) +{ + errno = ENOSYS; + return -1; +} + bool virIsDevMapperDevice(const char *dev_name G_GNUC_UNUSED) { return false; } -#endif /* ! WITH_DEVMAPPER */ +#endif /* ! defined(__linux__) */