Skip to contentSkip to conversation

Logging Access to HDD

DISCUSSION Sebastian Biedermann 5 participants 9 messages Apr 19, 2011

lore
Share & tools
lore
#0 lore raw

Dear List,

I´m working in research and I tought this list could be a good adress for my questions.

I want to log the disk accesses of the virtual hvm instances running in Xen. That means for the start I want to log the write querys of a running domU instance in the dom0 instance.

So I´m trying to modify the Xen 3.2.1 source code,
but actually I was not able to find a good entry point to do this.

For now, I want to log the disk accesses of a running windows 7 domU instance. The best what could happenis that I could see even the source and target of a hdd write query.

Does anyone have an idea how I could do this on a good way?
Which Xen source file / function should I modify? Where is the best entry point to do this?

Thank you a lot.

Signature · 1 line
Sebastian Biedermann
#1 lore raw
Quoted 12 lines

Dear List,

I´m working in research and I tought this list could be a good adress for my questions.

I want to log the disk accesses of the virtual hvm instances running in Xen. That means for the start I want to log the write querys of a running domU instance in the dom0 instance.

So I´m trying to modify the Xen 3.2.1 source code,
but actually I was not able to find a good entry point to do this.

Quoted 8 lines

For now, I want to log the disk accesses of a running windows 7 domU instance.
The best what could happenis that I could see even the source and target of a hdd write query.

Does anyone have an idea how I could do this on a good way? Which Xen source file / function should I modify? Where is the best entry point to do this?

HVM access can either be emulated PCI IDE, or PV. For the emulated access you would hook into qemu, I think. For PV access you would need to hook into whatever block device backend you are using.

Do you just want to count reads and writes, or do you want to log every single byte read/written?

James

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#2 lore raw

Am 19.04.2011 11:35, schrieb James Harper:

Quoted 17 lines
Quoted 17 lines

Dear List,

I´m working in research and I tought this list could be a good adress for my questions.

I want to log the disk accesses of the virtual hvm instances running in Xen. That means for the start I want to log the write querys of a running domU instance in the dom0 instance.

So I´m trying to modify the Xen 3.2.1 source code,
but actually I was not able to find a good entry point to do this.

For now, I want to log the disk accesses of a running windows 7 domU instance.
The best what could happenis that I could see even the source and target of a hdd write query.

Quoted 8 lines
Quoted 3 lines

Does anyone have an idea how I could do this on a good way? Which Xen source file / function should I modify? Where is the best entry point to do this?

HVM access can either be emulated PCI IDE, or PV. For the emulated access you would hook into qemu, I think. For PV access you would need to hook into whatever block device backend you are using.

Do you just want to count reads and writes, or do you want to log every single byte read/written?

James

I dont need to log every single byte, it would be enough to know which file is accessed by the domU inside its image. So when I use HVM I need to modify qemu and not the xen source?

thanks

Signature · 1 line
Sebastian
#3 lore raw
Quoted 23 lines · Sebastian Biedermann

Am 19.04.2011 11:35, schrieb James Harper:

Quoted 22 lines
Quoted 12 lines

Dear List,

I´m working in research and I tought this list could be a good adress for my questions.

I want to log the disk accesses of the virtual hvm instances running in Xen. That means for the start I want to log the write querys of a running domU instance in the dom0 instance.

So I´m trying to modify the Xen 3.2.1 source code,
but actually I was not able to find a good entry point to do this.

Quoted 8 lines

For now, I want to log the disk accesses of a running windows 7 domU instance.
The best what could happenis that I could see even the source and target of a hdd write query.

Does anyone have an idea how I could do this on a good way? Which Xen source file / function should I modify? Where is the best entry point to do this?

HVM access can either be emulated PCI IDE, or PV. For the emulated access you would hook into qemu, I think. For PV access you would need to hook into whatever block device backend you are using.

Quoted 9 lines
Quoted 3 lines

Do you just want to count reads and writes, or do you want to log every single byte read/written?

James

I dont need to log every single byte, it would be enough to know which file is accessed by the domU inside its image.
So when I use HVM I need to modify qemu and not the xen source?

thanks

Sebastian, QEMU is used by Xen for HVM guests. It's in the Xen source codes in the tools/ioemu-dir so look there and here it depends on disk type you're having - whether SCSI or IDE disk or whether you're using PV drivers. This can be found in the Xen domain configuration, i.e. if you're using file:/path/to/image,xvda then you're using PV drivers (they have to be installed in the guest), for hda instead of xvda you're using IDE disk and for sda instead of xvda you're using SCSI disk. If you're using PV drivers then you have to modify the PV drivers themselves and not QEMU so I'd recommend to use SCSI or IDE disk instead. For SCSI disk it's the best since you have the logic in the ioemu-dir/hw/scsi-disk.c AFAIK.

Michal

Signature · 2 lines
Michal Novotny <[email protected]>, RHCE
Virtualization Team (xen userspace), Red Hat
#4 lore raw

Am 19.04.2011 11:54, schrieb Michal Novotny:

Quoted 45 lines · Sebastian Biedermann
Quoted 23 lines

Am 19.04.2011 11:35, schrieb James Harper:

Quoted 22 lines
Quoted 12 lines

Dear List,

I´m working in research and I tought this list could be a good adress for my questions.

I want to log the disk accesses of the virtual hvm instances running in Xen. That means for the start I want to log the write querys of a running domU instance in the dom0 instance.

So I´m trying to modify the Xen 3.2.1 source code,
but actually I was not able to find a good entry point to do this.

Quoted 8 lines

For now, I want to log the disk accesses of a running windows 7 domU instance.
The best what could happenis that I could see even the source and target of a hdd write query.

Does anyone have an idea how I could do this on a good way? Which Xen source file / function should I modify? Where is the best entry point to do this?

HVM access can either be emulated PCI IDE, or PV. For the emulated access you would hook into qemu, I think. For PV access you would need to hook into whatever block device backend you are using.

Quoted 9 lines
Quoted 3 lines

Do you just want to count reads and writes, or do you want to log every single byte read/written?

James

I dont need to log every single byte, it would be enough to know which file is accessed by the domU inside its image.
So when I use HVM I need to modify qemu and not the xen source?

thanks

Sebastian, QEMU is used by Xen for HVM guests. It's in the Xen source codes in the tools/ioemu-dir so look there and here it depends on disk type you're having - whether SCSI or IDE disk or whether you're using PV drivers. This can be found in the Xen domain configuration, i.e. if you're using file:/path/to/image,xvda then you're using PV drivers (they have to be installed in the guest), for hda instead of xvda you're using IDE disk and for sda instead of xvda you're using SCSI disk. If you're using PV drivers then you have to modify the PV drivers themselves and not QEMU so I'd recommend to use SCSI or IDE disk instead. For SCSI disk it's the best since you have the logic in the ioemu-dir/hw/scsi-disk.c AFAIK.

Quoted 2 lines

Michal

Okay, that sounds good, I will try to modifiy the ioemu ide drivers to see which sectors are used and I will try to match these sectors to the upper layer of the image of the guestU tofind out which data files are accessed. Hope that works :-)

Thank you!

Signature · 10 lines
Sebastian Biedermann
Security Engineering Group
Technische Universität Darmstadt
Mornewegstraße 32, 64293 Darmstadt
Phone: +49-6151-16-75146

This email and any files transmitted with it are confidential
and intended solely for the use of the individual or entity
to whom they are addressed. If you have received this email
in error please notify the sender.
#5 lore raw
In reply to Sebastian Biedermann

Am 19.04.2011 11:44, schrieb Sebastian Biedermann:

Quoted 3 lines

I dont need to log every single byte, it would be enough to know which file is accessed by the domU inside its image.
So when I use HVM I need to modify qemu and not the xen source?

Won't work: the outer layer only sees block accesses, and not "actual" file accesses, so you're only able to log (if patching qemu) which blocks of the virtualized hard disk of your Windows system are accessed. You'd need to correlate this to additional data that's stored on the disk itself to find out which file a block that's accessed by the system belongs to.

Doing this kind of correlation from the outside is hard, and it should be much easier to plug a device driver into Windows itself which intercepts the filesystem calls in NTFS.sys (which implements the VFS for NTFS accesses under windows) to retrieve the accessed files from the system itself (namely at the layer which knows about the filesystem structure of an NTFS filesystem, which qemu as hardware virtualizer does not).

Signature · 1 line
--- Heiko.
#6 lore raw
Quoted 11 lines · Heiko Wundram

Am 19.04.2011 11:44, schrieb Sebastian Biedermann:

Quoted 3 lines

I dont need to log every single byte, it would be enough to know which file is accessed by the domU inside its image.
So when I use HVM I need to modify qemu and not the xen source?

Won't work: the outer layer only sees block accesses, and not "actual" file accesses, so you're only able to log (if patching qemu) which blocks of the virtualized hard disk of your Windows system are accessed. You'd need to correlate this to additional data that's stored on the disk itself to find out which file a block that's accessed by the system belongs to.

Quoted 8 lines

Doing this kind of correlation from the outside is hard, and it should be much easier to plug a device driver into Windows itself which intercepts the filesystem calls in NTFS.sys (which implements the VFS for NTFS accesses under windows) to retrieve the accessed files from the system itself (namely at the layer which knows about the filesystem structure of an NTFS filesystem, which qemu as hardware virtualizer does not).

That's right. I remember some time ago I've been using API hooking techniques to do similar stuff so if you implement an API hook directly to Windows you can achieve the job of file changes. More over, I think Windows is having some iNotify-like API as well - something like FindFirstChange() or similar...

Michal

Signature · 2 lines
Michal Novotny <[email protected]>, RHCE
Virtualization Team (xen userspace), Red Hat
#8 lore raw
Quoted 10 lines · Laszlo Ersek
Quoted 4 lines · Sebastian Biedermann
Quoted 2 lines
Quoted 2 lines

For now, I want to log the disk accesses of a running windows 7 domU instance.

I dont need to log every single byte, it would be enough to know which file is accessed by the domU inside its image.

Perhaps try Filemon from Sysinternals ^W^W^W Process Monitor:

http://technet.microsoft.com/en-us/sysinternals/bb896645

Laszlo, those tools are basically using the API I mentioned above - the FindFirstChange() or similar API I already mentioned. If Sebastian wants it to be done for one-time or user-assisted monitoring then it's fine to use those Sysinternals utilities however if his intention is to create an application to be monitoring it "on-the-fly" then writing his own app is better.

Michal

Signature · 2 lines
Michal Novotny <[email protected]>, RHCE
Virtualization Team (xen userspace), Red Hat