[PATCH 3/5] util: introduce readonly attribute to virPCIDeviceConfigOpenInternal

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Allow wrappers to open PCI config as read-only.

Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
---
 src/util/virpci.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/util/virpci.c b/src/util/virpci.c
index c1dad1e69f..e45dfbc631 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -291,11 +291,11 @@ virPCIDeviceGetDriverPathAndName(virPCIDevicePtr dev, char **path, char **name)
 
 
 static int
-virPCIDeviceConfigOpenInternal(virPCIDevicePtr dev, bool fatal)
+virPCIDeviceConfigOpenInternal(virPCIDevicePtr dev, bool readonly, bool fatal)
 {
     int fd;
 
-    fd = open(dev->path, O_RDWR);
+    fd = open(dev->path, readonly ? O_RDONLY : O_RDWR);
 
     if (fd < 0) {
         if (fatal) {
@@ -317,13 +317,13 @@ virPCIDeviceConfigOpenInternal(virPCIDevicePtr dev, bool fatal)
 static int
 virPCIDeviceConfigOpen(virPCIDevicePtr dev, bool fatal)
 {
-    return virPCIDeviceConfigOpenInternal(dev, fatal);
+    return virPCIDeviceConfigOpenInternal(dev, false, fatal);
 }
 
 static int
 virPCIDeviceConfigOpenWrite(virPCIDevicePtr dev)
 {
-    return virPCIDeviceConfigOpenInternal(dev, true);
+    return virPCIDeviceConfigOpenInternal(dev, false, true);
 }
 
 static void
-- 
2.20.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux