Bug 394348 - Umounting mounted disk image (e.g. .iso file) does not remove it from Device Notifier
Summary: Umounting mounted disk image (e.g. .iso file) does not remove it from Device ...
Status: RESOLVED FIXED
Alias: None
Product: frameworks-solid
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 5.46.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Lukáš Tinkl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-16 20:50 UTC by Anthony Fieroni
Modified: 2020-11-03 06:11 UTC (History)
10 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.65


Attachments
solid-hardware5_details_before_mounting (823 bytes, text/plain)
2018-09-10 19:47 UTC, Nick Stefanov
Details
solid-hardware5_details_after_mounting (837 bytes, text/plain)
2018-09-10 19:47 UTC, Nick Stefanov
Details
solid-hardware5_details_before_mounting_after reboot (819 bytes, text/plain)
2018-09-10 19:56 UTC, Nick Stefanov
Details
solid-hardware5_details_after_mounting_after reboot_CDEmu_Virt_2e_CD_2fDVD_ROM (820 bytes, text/plain)
2018-09-10 19:56 UTC, Nick Stefanov
Details
solid-hardware5_details_after_mounting_after reboot_CDEmu_Virt_2e_CD_2fDVD_ROM_1 (836 bytes, text/plain)
2018-09-10 19:56 UTC, Nick Stefanov
Details
After doing "Release" from Dolphin (54.88 KB, image/png)
2018-10-01 22:34 UTC, Stefan Brüns
Details
Handle media change events for devices that are connected after initial introspection (1.74 KB, patch)
2019-04-12 22:21 UTC, Rok Mandeljc
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Anthony Fieroni 2018-05-16 20:50:51 UTC
Unounting flash drive works as expected e.g. notification tray icon goes empty and hide, but umounting iso image via eject buttons, does not hide entry even menu is still accessible but image is *really* umounting - /run/media/<mount-point> is empty. So i think is Solid related bug, please fix me if i'm wrong. It'll follow a screenshot by original reporter.
Comment 1 Nick Stefanov 2018-05-16 21:30:03 UTC
CD/DVD images aren't ejected properly when cdemu is being used. After they been ejected device notifier still lists them. Dolphin lists them too in the device section.

Actually the folder in /run/media/user disappears after unmounting but the image (.iso, bin, etc) is still present in the device notifier and Dolphin. This happens only with CD/DVD images. With flash drives all works as intended. Here you are some screenshots:

The image is mounted and is properly listed in Dolphin and device manager:
https://s7.postimg.cc/apt0ux5l7/image.png
https://s7.postimg.cc/6goastmx7/image.png

The folder in /run/media/user is also there:
https://s7.postimg.cc/jm3syhlt7/image.png

When the image is being ejected from Dolphin or the device manager, the folder in /run/media/user disappears but Dolphin and the device manager continue to list it. If you close and open Dolphin, the image disappears from it's device list, but it is actually there and it exists in the device manager and the icon for pluged removable devices is still being shown in the panel. This icon can onle be removed if the DE or machine is restarted.

Here are some screenshots:
The image is unmounted either from Dolphin or from the device manager. It makes no difference, the result is all the same. The options for eject or release are gone:
https://s7.postimg.cc/41wf8696j/image.png

The folder in /run/media/user has diappeared:
https://s7.postimg.cc/xtthn6o8b/image.png

The icon in the panel is still here and the device manager still lists the image file with the three actions for this mime type which doesn't work for the image isn't there:
https://s7.postimg.cc/kqxv3txzf/image.png
https://s7.postimg.cc/ru5qjwdu3/Screenshot_20180517_002007.png

If one of the three options are being chosen, the malformed url error appears because the image is gone:
https://s7.postimg.cc/era40mvbv/image.png
Comment 2 Nick Stefanov 2018-06-17 16:43:48 UTC
Is the thread in the right place? Why ignoring it?
Comment 3 Nick Stefanov 2018-06-24 20:25:36 UTC
Hello, anybody???
Comment 4 Christoph Feck 2018-06-25 00:46:53 UTC
The solid framework currently has no maintainer. It looks like you investigated a lot, maybe you could even propose a patch to fix this issue?
Comment 5 Nick Stefanov 2018-06-25 08:55:33 UTC
I wish to but I can't. I don't have the knowledge :(
Comment 6 Kai Uwe Broulik 2018-06-27 17:57:15 UTC
From what I can tell when unmounting, the device loses its "FileSystem" interface at which point it will be ignored, hence it not showing up when restarting Dolphin.
However, the device itself isn't actually removed, so the filtered list isn't updated. Not sure how to fix this.
The "autoclear" flag (-o loop) has no effect.
Comment 7 Anthony Fieroni 2018-06-27 18:19:49 UTC
Does it eject is pressed then solid umount and should fire Solid::DeviceNotifier::deviceRemoved then DeviceNotifier should became empty no?
Comment 8 Nick Stefanov 2018-08-02 12:59:28 UTC
I get the Antony's patch from here:
https://phabricator.kde.org/D13869
I use it two weeks already and so far I haven't any problems at all. The patch works flawlessly for me. Kudos to anthonyfieroni for providing fix for this annoying problem.
Comment 9 Stefan Brüns 2018-08-14 13:03:59 UTC
Git commit 8e9fc89918c4a8817b624a61e0d2d32d349722cc by Stefan Brüns.
Committed on 14/08/2018 at 13:03.
Pushed by bruns into branch 'master'.

Force reevaluation of Predicates if interfaces are removed

Summary:
If an application wants to show only specicific devices based on predicate
matching, and one of the matching devices loses an interface which is
critical for the Predicate to match, the application has to be notified.

As there is no dedicated signal to notify the application about the
fact a device no longer has e.g. a Solid::StorageAccess iface, signal the
device has been removed, and immediately readd it, as the device may
still be relevant.

Remove the call to updateBackend(udi), as the device backend listens to
the InterfacesRemoved signal itself and updates its property cache.

Test Plan:
1. Image file mounting via loop-back
  - udisksctl loop-setup -f ~/fat.img
  -> Icon appears under "Devices"
  - unmount via context-menu in dolphin
  -> device icon stays in "Devices"
  - set "Auto-clear" flag on loop (e.g. losetup --detach-all)
  - remount
  - unmount
  -> device icon vanishes from "Devices"
2. CD-ROM/DVD
  -  icon appear when a non-blank medium is inserted
  - vanishes on medium removal
3. USB stick
  - for each mountable filesystem, an icon appears under "Removable devices"
  - formatting a partition with a non-mountable filesystem/blank removes the entry
  - formatting with a mountable FS (re)adds the entry

Reviewers: #frameworks, broulik, ngraham, apol

Reviewed By: broulik

Subscribers: apol, anthonyfieroni, kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D14661

M  +20   -3    src/solid/devices/backends/udisks2/udisksmanager.cpp

https://commits.kde.org/solid/8e9fc89918c4a8817b624a61e0d2d32d349722cc
Comment 10 Nick Stefanov 2018-09-10 08:43:06 UTC
Hello,
now in Solid 5.50 the problem is solved partially. When mount CD/DVD and then unmount it, the Dolphin icon in the side bar disappears but the device manager icon stays in the system tray and there's no way to remove it. The only way is to restart the system. After unmounting CD/DVD we get this with no option to exit from this notification. The icon is always there:

https://s15.postimg.cc/886itqnmz/image.png

With Anthony Fieroni's patch there isn't such problem. When unmounting CD/DVD both icons disappears immediately - the one in Dolphin's side bar and the one in the system tray. Please fix this annoying behaviour. Thank you.
Comment 11 Patrick Silva 2018-09-10 15:15:56 UTC
I can confirm the problem described in comment 10 on Arch Linux + frameworks 5.50 when I mount the ISO image using cdemu.
When I use Gnome disks ("disk image mounter" in dolphin context menu) to mount the ISO instead cdemu a new entry appears in the side bar of Dolphin under "Devices" instead under "Removable devices" and no related entry appears in device notifier applet.
Comment 12 Stefan Brüns 2018-09-10 15:19:11 UTC
(In reply to Nick Stefanov from comment #10)
> Hello,
> now in Solid 5.50 the problem is solved partially. When mount CD/DVD and
> then unmount it, the Dolphin icon in the side bar disappears but the device
> manager icon stays in the system tray and there's no way to remove it. 

Please be more specific.

Physical CD/DVD drive or iso image?

Please provide the output of "solid-hardware5 details" for the relevant UDI, both mounted and unmounted.
Comment 13 Nick Stefanov 2018-09-10 15:22:47 UTC
Umounting mounted disk image (e.g. .iso file), as the title says.
Comment 14 Nick Stefanov 2018-09-10 15:28:33 UTC
I don't know how to get udi solid-hardware5 details. Can you help with this?
Comment 15 Kai Uwe Broulik 2018-09-10 15:56:13 UTC
Check solid-hardware5 list, it lists all your devices, most like one of those that start with /org/freedesktop/UDisks2
Comment 16 Nick Stefanov 2018-09-10 16:12:06 UTC
Thank you very much :)

Here is the output without mounted image:
https://pastebin.com/TQxwzUpD

And with mounted ISO:
https://pastebin.com/sUNYGNWB
Comment 17 Stefan Brüns 2018-09-10 17:51:40 UTC
You need to run "solid-hardware5 details <UDI>", e.g. "solid-hardware details /org/freedesktop/UDisks2/drives/CDEmu_Virt_2e_CD_2fDVD_ROM"

Run it after mounting and after unmounting, and, *please*, give your logs a speaking name.

Also run "sudo losetup -a" after mounting and unmounting.
Comment 18 Nick Stefanov 2018-09-10 18:34:37 UTC
I see, sorry :)

Here it is with no mounted image:
https://pastebin.com/D6jfZaqm

And with mounted image:
https://pastebin.com/bnctGbM6

sudo losetup -a gives no output no matter if image is mounted or not.

What do you mean with "speaking name"? English is not my native language and for me is difficult to understand, sorry.
Comment 19 Stefan Brüns 2018-09-10 19:11:37 UTC
The logs still do not provide the required information, as you used the wrong UDI. 

CDEmu seems to create new virtual drives when mounting images. Make sure you use the UDI matching the drive you are currently using.

check "solid-hardware5 list | grep CDEmu" for possible UDIs.

Speaking name - e.g. "solid-hardware5_details_after_mounting.txt"
Comment 20 Nick Stefanov 2018-09-10 19:44:37 UTC
The "solid-hardware5 list | grep CDEmu" command gives only two possible devices:

udi = '/org/freedesktop/UDisks2/drives/CDEmu_Virt_2e_CD_2fDVD_ROM_1'
udi = '/org/freedesktop/UDisks2/drives/CDEmu_Virt_2e_CD_2fDVD_ROM'

I already gave you logs for udi = '/org/freedesktop/UDisks2/drives/CDEmu_Virt_2e_CD_2fDVD_ROM. Do you need the logs for udi = '/org/freedesktop/UDisks2/drives/CDEmu_Virt_2e_CD_2fDVD_ROM_1?

Actually this problem is present everywhere. Can't you get the needed info from your system?
Comment 21 Nick Stefanov 2018-09-10 19:47:25 UTC
Created attachment 114883 [details]
solid-hardware5_details_before_mounting
Comment 22 Nick Stefanov 2018-09-10 19:47:41 UTC
Created attachment 114884 [details]
solid-hardware5_details_after_mounting
Comment 23 Nick Stefanov 2018-09-10 19:54:45 UTC
I rebooted and the "solid-hardware5 list | grep CDEmu" command now gives only one possible device:

udi = '/org/freedesktop/UDisks2/drives/CDEmu_Virt_2e_CD_2fDVD_ROM'

When I mount an image after the reboot, the command gives again two possible devices:

udi = '/org/freedesktop/UDisks2/drives/CDEmu_Virt_2e_CD_2fDVD_ROM_1'
udi = '/org/freedesktop/UDisks2/drives/CDEmu_Virt_2e_CD_2fDVD_ROM

Now I'll attach logs after the reboot.
Comment 24 Nick Stefanov 2018-09-10 19:56:13 UTC
Created attachment 114885 [details]
solid-hardware5_details_before_mounting_after reboot
Comment 25 Nick Stefanov 2018-09-10 19:56:34 UTC
Created attachment 114886 [details]
solid-hardware5_details_after_mounting_after reboot_CDEmu_Virt_2e_CD_2fDVD_ROM
Comment 26 Nick Stefanov 2018-09-10 19:56:51 UTC
Created attachment 114887 [details]
solid-hardware5_details_after_mounting_after reboot_CDEmu_Virt_2e_CD_2fDVD_ROM_1
Comment 27 Stefan Brüns 2018-09-14 01:16:36 UTC
The solid core is working as expected, but some of its signals are not handled in the solid dataengine, which the applet relies on.
Comment 28 Stefan Brüns 2018-09-21 18:22:43 UTC
(In reply to Stefan Brüns from comment #27)
> The solid core is working as expected, but some of its signals are not
> handled in the solid dataengine, which the applet relies on.

The plasma engine explorer shows events (source added/removed) are generated by the hotplug data engine, and the solid dataengine shows the current values.

Next step look into the applet itself why is does not react on the events (it is hooked to both hotplug and solid dataengine as sources).
Comment 29 Nick Stefanov 2018-09-21 19:42:16 UTC
You can look at Fieroni's patch. It works perfect for me and I'm using it for two months already and without a single problem :)
Comment 30 Stefan Brüns 2018-09-21 21:26:08 UTC
(In reply to Nick Stefanov from comment #29)
> You can look at Fieroni's patch. It works perfect for me and I'm using it
> for two months already and without a single problem :)

That does not "fix" the problem, but just has the desired effect by chance.

It breaks other use cases. It removes the whole device as soon as the filesystem is unmounted.
Comment 31 Nick Stefanov 2018-09-21 22:18:08 UTC
And why removing the whole device as soon as the filesystem is unmounted is a problem?
Comment 32 Stefan Brüns 2018-09-22 02:39:33 UTC
(In reply to Nick Stefanov from comment #31)
> And why removing the whole device as soon as the filesystem is unmounted is
> a problem?

Because the partition is the same device.

If you do not understand the difference, please educate yourself.
Comment 33 Stefan Brüns 2018-09-24 13:28:08 UTC
Git commit 61b2b173e8d68623a3681fd27c0ad0348bf41191 by Stefan Brüns.
Committed on 24/09/2018 at 13:27.
Pushed by bruns into branch 'master'.

[Device Notifier] Avoid accessing attributes of stale UDIs

Summary:
When a Solid device is removed (e.g. a CD is ejected) the notifier tries
to read the attributes although the Source for the UDI has just vanished.

Fixes several QML error messages, i.e. "TypeError: Cannot read property
'...' of undefined" and "Unable to assign [undefined] to QString".

Apparently these errors also have the effect of items showing outdated
state, i.e. optical media still being shown after ejecting it.

Test Plan:
1. insert optical medium
2. eject
Without the changes, the item was stuck
Now, the item is removed as soon as the medium is ejected

Also, no more errors are logged for the devicenotifier

Reviewers: #frameworks, broulik

Reviewed By: broulik

Subscribers: ngraham, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D15687

M  +6    -5    applets/devicenotifier/package/contents/ui/FullRepresentation.qml
M  +8    -0    applets/devicenotifier/package/contents/ui/devicenotifier.qml

https://commits.kde.org/plasma-workspace/61b2b173e8d68623a3681fd27c0ad0348bf41191
Comment 34 Nick Stefanov 2018-09-24 13:37:12 UTC
Thank you :)
Comment 35 Stefan Brüns 2018-09-30 00:13:25 UTC
@ Nick Stefanov - please confirm and set to fixed eventually.
Comment 36 Nick Stefanov 2018-09-30 15:06:07 UTC
Hello Stefan Brüns,

Unfortunately it doesn't work. I can't see any difference in the behaviour before and after.
Comment 37 Stefan Brüns 2018-09-30 15:18:57 UTC
(In reply to Nick Stefanov from comment #36)
> Hello Stefan Brüns,
> 
> Unfortunately it doesn't work. I can't see any difference in the behaviour
> before and after.

Are you sure you use a plasma version including the changes? There is no release yet where this is contained in.

If yes, please install plasmaengineexplorer and plasmoidviewer from the plasma SDK.

In the plasmaengineexplorer, select the hotplug engine. A '/org/freedesktop/UDisks2/block_devices/sr<N>' device/source should appear when the disk is inserted and vanish when the disk is ejected.

There is also the possibility CDEmu is not working as you might expect. If it does not "eject" the disk image when it is removed, solid still sees a medium inside the drive, and thus shows the entries for the medium.
Comment 38 Nick Stefanov 2018-09-30 15:40:10 UTC
I use CDEmu with other desktop environments including KDE 4 and it works perfectly. This problem exists only in Plasma.

For testing the changes I got the files FullRepresentation.qml and devicenotifier.qml from here:
https://cgit.kde.org/plasma-workspace.git/tree/applets/devicenotifier/package/contents/ui

and replaced them. I also restarted the machine.
Comment 39 Stefan Brüns 2018-09-30 15:41:25 UTC
(In reply to Nick Stefanov from comment #38)
> I use CDEmu with other desktop environments including KDE 4 and it works
> perfectly. This problem exists only in Plasma.

Thats not what I asked ...
Comment 40 Nick Stefanov 2018-09-30 15:43:05 UTC
I'm regular user and these thigs are difficult for me. You asked me how I tested the changes and I answered.
Comment 41 Nick Stefanov 2018-09-30 21:04:42 UTC
Now I tested with plasmaengineexplorer. When I mount an image a /org/freedesktop/UDisks2/block_devices/sr3 appears:

https://i.imgur.com/qIR9yt5.png

When I unmount the image, the /org/freedesktop/UDisks2/block_devices/sr3 disappears but the icon in the system tray remains:

https://i.imgur.com/LAh2b3k.png
Comment 42 Stefan Brüns 2018-09-30 22:02:27 UTC
Please try to run the notifier using plasmoidviewer and see if it works there:

$> plasmoidviewer -a org.kde.plasma.devicenotifier
Comment 43 Nick Stefanov 2018-10-01 06:57:22 UTC
No, it doesn't work. When I moint an image it appears in the main window:
https://i.imgur.com/Fz5yWSY.png

When I unmount it, the item in the Dolphin's device section disappears but the icon in the system tray and in the plasmoidviewer remains:
https://i.imgur.com/xywlun8.png
Comment 44 Stefan Brüns 2018-10-01 11:34:46 UTC
The "virtual disk" is still inside the virtual drive. You can copy it with k3b.

If you want to have the image "ejected" whenever it is unmounted, talk to the CDEmu devs, there is nothing we can do here.

Everything works exactly as designed. Not our bug.
Comment 45 Anthony Fieroni 2018-10-01 11:50:18 UTC
K3B uses Solid as well, so the problem remains there, about me.
Comment 46 Stefan Brüns 2018-10-01 11:54:08 UTC
(In reply to Anthony Fieroni from comment #45)
> K3B uses Solid as well, so the problem remains there, about me.

Press the eject button! Solid is just telling the truth, you have a CD drive with a medium in it.
Comment 47 Anthony Fieroni 2018-10-01 12:05:20 UTC
But he umounts image, there is noting to press, virtual image is gone.
Comment 48 Stefan Brüns 2018-10-01 13:51:46 UTC
(In reply to Anthony Fieroni from comment #47)
> But he umounts image, there is noting to press, virtual image is gone.

Unmounting means you can no longer access the file system. You can still access the drive and the inserted medium, e.g. with k3b.

The entry will vanish as soon as there no longer is a medium in the drive.

CDEmu emulates a CD/DVD drive. If the emulation is incomplete/broken, this is not solids fault.
Comment 49 Nick Stefanov 2018-10-01 17:38:37 UTC
The image IS ejected but there is icon with virt. CD/DVD ROM in the sys tray and there isn't eject icon. Why? Because the disk is ejected. CDEmu works just fine in Cinnamon, LXDE, Gnome and Xfce. Where is the problem then? In CDEmu? No it isn't.
Comment 50 Anthony Fieroni 2018-10-01 17:52:39 UTC
Ok, if you click on it, when it's ejected or umount, will it mount and usable again?  If yes that's good because you can use it again easily, if not that's a problem.
Comment 51 Nick Stefanov 2018-10-01 17:58:02 UTC
Antoni, no, tehere isn't a way to remount. Just an option to Copy it with K3b wich doesn't work for obvious reasons:
https://i.imgur.com/okpVuQT.png

CDEmu works ok in KDE 4 too. Stefan Brüns, do you wish to record a clip for you with KDE 4 where all works as expected? With the exactly the same version of CDEmu?
Comment 52 Anthony Fieroni 2018-10-01 19:44:18 UTC
So looks like device has still have CD/DVD reads ability/ies 
https://phabricator.kde.org/source/k3b/browse/master/libk3bdevice/k3bdevicemanager.cpp$388-391
that's why K3b shows it?
Comment 53 Stefan Brüns 2018-10-01 20:05:39 UTC
(In reply to Anthony Fieroni from comment #52)
> So looks like device has still have CD/DVD reads ability/ies 
> https://phabricator.kde.org/source/k3b/browse/master/libk3bdevice/
> k3bdevicemanager.cpp$388-391
> that's why K3b shows it?

More or less, K3B tells the device notifier (via /usr/share/solid/actions/k3b_*.desktop) to show it.
Comment 54 Nate Graham 2018-10-01 20:06:44 UTC
In other words, the bug in Solid has been fixed, and if there is a remaining issue here, it's in k3b, right?
Comment 55 Anthony Fieroni 2018-10-01 20:25:40 UTC
I'm not sure that bug is in k3b.
Comment 56 Nick Stefanov 2018-10-01 20:36:27 UTC
In fact I just removed K3b and now everything works as expected. It's strange however that in KDE 4 all works perfect without need of K3b uninstallation.
Comment 57 Stefan Brüns 2018-10-01 22:22:33 UTC
(In reply to Nick Stefanov from comment #56)
> In fact I just removed K3b and now everything works as expected. It's
> strange however that in KDE 4 all works perfect without need of K3b
> uninstallation.

Cinnamon, LXDE, Gnome and KDE4 do not integrate with K3B.
Comment 58 Nate Graham 2018-10-01 22:30:43 UTC
Seems like this fixed in Solid, so please file a new bug against K3B. Thanks!
Comment 59 Stefan Brüns 2018-10-01 22:34:02 UTC
Created attachment 115354 [details]
After doing "Release" from Dolphin
Comment 60 Stefan Brüns 2018-10-01 22:48:47 UTC
Its not a bug in K3B, but in CDEmu. I have just verified "Releasing" (aka unmounting) a *real* CD from a real drive, and it stays in the device notifier, giving the option to remount, copy with k3b or open in various programs (implicitly remounting it).

When I press eject (either in the device notifier, or from the dolphin context menu), it vanishes.
Comment 61 Nate Graham 2018-10-01 23:31:01 UTC
semi-relatedly: I bet we could get people to stop using cdemu if we had native ISO mounting support in Dolphin (Bug 175051).
Comment 62 Rok Mandeljc 2019-04-12 22:21:18 UTC
Created attachment 119390 [details]
Handle media change events for devices that are connected after initial introspection

(In reply to Stefan Brüns from comment #60)
> Its not a bug in K3B, but in CDEmu. I have just verified "Releasing" (aka
> unmounting) a *real* CD from a real drive, and it stays in the device
> notifier, giving the option to remount, copy with k3b or open in various
> programs (implicitly remounting it).
> 
> When I press eject (either in the device notifier, or from the dolphin
> context menu), it vanishes.

Hello,

this bug report was linked in a bug report opened against CDEmu.

However, as far as I can tell, this is an issue with Solid, because I can also reproduce it with my USB optical drive (ASUS BW-12D1S-U) - if I connect it to system after Plasma session has been started.

More specifically, the issue is that in udisks2 backend, Manager::slotMediaChanged() is connected to udisks2' PropertiesChanged signal only for UDIs that are present during the initial Manager::allDevices() call (which probably happens at session startup). For devices that are connected later (such as a CDEmu virtual device, or an external USB drive), this connection is not established. Consequently, the medium change is not properly detected and available Content is not updated, and so its stale content triggers the K3b Device action due to content-based predicate still evaluating as true.

I have attached a proof-of-concept patch that seems to fix the issue for me. It is based on assumption that addition of "org.freedesktop.UDisks2.Block" interface means that a new device has been added, and it that case checks if it is an optical device (in the same way as is done in Manager::introspect()).
Comment 63 Nate Graham 2019-04-13 14:26:07 UTC
Thanks for the patch! Can you submit it on https://phabricator.kde.org?

using the `arc` command-line tool is the preferred method (see https://community.kde.org/Infrastructure/Phabricator#Using_Arcanist_to_post_patches) but seeing as you have a diff, you can also use the web interface (see https://community.kde.org/Infrastructure/Phabricator#Posting_a_Patch_using_the_website).

Thanks again!
Comment 64 Rok Mandeljc 2019-04-13 14:50:07 UTC
Patch submitted to Phabricator: https://phabricator.kde.org/D20508
Comment 65 Nate Graham 2019-04-13 15:32:26 UTC
Thank you! I'll keep an eye on that.
Comment 66 Nick Stefanov 2019-04-13 15:34:39 UTC
Will you inform us when the patch goes upstream?
Comment 67 Patrick Silva 2019-04-13 21:35:18 UTC
I'm not a software developer, but I applied Rok's patch on Arch Linux and it fixes the problem when unmounting ISO images.
Comment 68 Nate Graham 2019-04-13 21:44:53 UTC
(In reply to Patrick Silva from comment #67)
> I'm not a software developer, but I applied Rok's patch on Arch Linux and it
> fixes the problem when unmounting ISO images.

Thanks Patrick. Would you be able to leave that comment on the review page too? https://phabricator.kde.org/D20508
Comment 69 Patrick Silva 2019-07-17 16:16:28 UTC
This bug persists.

Operating System: Arch Linux 
KDE Plasma Version: 5.16.3
KDE Frameworks Version: 5.60.0
Qt Version: 5.13.0
Comment 70 Nick Stefanov 2019-07-17 16:19:08 UTC
Yes, it's still here.
Comment 71 Nick Stefanov 2019-09-07 11:25:06 UTC
Hello,
The bug is still here but this time without k3b installed. It appeared some days ago. When you discover k3b is the problem I uninstalled it and everything was working fine till the day before yesterday or one dy before it. I check 3 times if I have k3b installed - it's not installed but the problem is here.
Comment 72 sokoban 2019-09-07 11:47:47 UTC
Hello,
The bug is still persist 
Operating System: Manjaro KDE 
KDE Plasma Version: 5.16.4
KDE Frameworks Version: 5.61.0
Qt Version: 5.13.0
Comment 73 sokoban 2019-09-07 12:02:43 UTC
And I not have k3b installed on my system
Comment 74 Nick Stefanov 2019-09-08 12:09:11 UTC
I figured out something - the problem occurs if I try to unmount the image from the panel's Device Notifier or from the Dolphin entry in the sidebar. If I eject it from CDEmu manager it unmounts properly. But it's irritating every time to start CDEmu and unmount...
Comment 75 Nick Stefanov 2019-09-12 08:12:37 UTC
I experience the same behaviour with gcdemu. The problem is obviously in Plasma. Please, fix it for it's a very irritating problem.
Comment 76 Nick Stefanov 2019-09-17 10:47:31 UTC
Anybody?
Comment 77 Nate Graham 2019-09-17 13:04:11 UTC
Kai, didn't you investigate this recently?
Comment 78 Nick Stefanov 2019-10-11 20:39:33 UTC
I noticed something interesting - if I unmount the previously mounted disk via device notifier or Dolphin and I close Dolphin, the mounted image is gone from the side bar's devices section after I open Dolphin again. But the device isn't released and no image can be mounted until I unmount the previous image via CDEmu or restart.
Comment 79 Patrick Silva 2019-10-14 18:32:19 UTC
(In reply to Nick Stefanov from comment #78)
> I noticed something interesting - if I unmount the previously mounted disk
> via device notifier or Dolphin and I close Dolphin, the mounted image is
> gone from the side bar's devices section after I open Dolphin again. But the
> device isn't released and no image can be mounted until I unmount the
> previous image via CDEmu or restart.

I have just reported an issue that seems related to your comment. See bug 412945.
Comment 80 Nick Stefanov 2019-10-16 15:14:31 UTC
Plasma 5.17 - the bug is still here in .
Comment 81 Nick Stefanov 2019-11-05 11:32:41 UTC
Plasma 5.17.1 - the bug is still here and it's still that annoying.
Comment 82 Nick Stefanov 2019-11-10 12:25:44 UTC
Plasma 5.17.2 - the bug is still here.
Comment 83 Christoph Feck 2019-11-11 03:47:57 UTC
Sure, if someone fixes this bug, the status will change to FIXED. There is no need to state the obvious multiple times.
Comment 84 Nick Stefanov 2019-11-11 08:10:08 UTC
But it's needed to remind that KDE is the only one DE with such a ridiculous bug but nobody cares.
Comment 85 Kai Uwe Broulik 2019-11-11 08:12:18 UTC
It is not.
Comment 86 Nick Stefanov 2019-11-11 08:23:52 UTC
Show me one? There isn't but KDE.
Comment 87 Kai Uwe Broulik 2019-11-11 08:25:49 UTC
I said it is not neccessary to constantly remind developers about a minor inconvenience. Just by replying to this bug report alone I wasted several minutes I could have spent doing something productive. If the bug is fixed, the bug report will be marked as such and closed, otherwise it might potentially even still be in Plasma version 23478923423.
Comment 88 Nick Stefanov 2019-11-11 08:50:04 UTC
Just as I said - nobody cares about this ridiculous bug including you.
Comment 89 Patrick Silva 2019-11-11 12:43:31 UTC
it's bacause things like this bug that open source software probably will never be a good alternative for desktop users.

fortunately https://phabricator.kde.org/D20508 was accepted and probably this annoying bug will be fixed in frameworks 5.65.
Comment 90 Nick Stefanov 2019-11-11 14:23:03 UTC
rokmandeljc and Nate, thank you!
Comment 91 Nate Graham 2019-11-12 17:38:12 UTC
Git commit 4aa39aed1bd6c81dbf0d6dc9d312af5340f7caab by Nate Graham, on behalf of Rok Mandeljc.
Committed on 12/11/2019 at 17:38.
Pushed by ngraham into branch 'master'.

[udisks2] fix media change detection for external optical drives

Summary:
If an external optical drive is connected after Solid does its initial introspection, the resulting UDI does not get a mediaChanged signal/slot connection, and thus fails to react to the media change. Consequently, disc content is not properly updated after the medium is ejected, causing bug #394348.

This patch assumes that an addition of "org.freedesktop.UDisks2.Block" interface means that a new device has been added; in this case, it performs Device::mightBeOpticalDisc() check to add the slotMediaChanged() connection.
FIXED-IN: 5.65

Test Plan:
Test steps:
1. Start KDE Plasma session. Make sure K3b is installed.
2. Connect an external USB optical drive.
3. Insert the disc
4. Observe Device action notifications for the inserted disc.
5. Eject the disc.
6. Observe Device action notifications.

Behavior before patch: after disc is ejected, a "Copy with K3b" action remains available for the drive
See: https://bugs.kde.org/show_bug.cgi?id=394348

Behavior after patch: after disc is ejected, no actions remain available for the drive

Reviewers: bruns, broulik, dfaure, #frameworks, ngraham

Reviewed By: ngraham

Subscribers: ngraham, bugseforuns, kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D20508

M  +12   -0    src/solid/devices/backends/udisks2/udisksmanager.cpp

https://commits.kde.org/solid/4aa39aed1bd6c81dbf0d6dc9d312af5340f7caab
Comment 92 Nick Stefanov 2019-11-12 18:16:19 UTC
Nate,
At the moment the bug is present with K3B uninstalled. Uninstalling K3B used to resolve this bug some time ago but no more. I hope this patch will address the new behaviour.
Comment 93 Nick Stefanov 2019-12-20 16:27:14 UTC
Today KDE Frameworks 5.65 came to Arch. I can confirm the problem is NOT fixed. There aren't any change in the behaviour at all... I tried uninstalling K3b to no avail.
Comment 94 Nick Stefanov 2019-12-27 16:28:33 UTC
Here's the video of the problem:

https://youtu.be/G6WwSZWyTlA

On every other DE the mounted disk disappears after it's being ejected either from the side the bar or system tray. On KDE it's still there and we can't mount another image till it's ejected with CDEmu. So unfortunately the newest patch does nothing.
Comment 95 Nick Stefanov 2019-12-27 16:29:29 UTC
Ah, almost forget - this is a brand new user profile.
Comment 96 Rok Mandeljc 2019-12-27 21:12:02 UTC
(In reply to Nick Stefanov from comment #95)
> Ah, almost forget - this is a brand new user profile.

Can you try reproducing this with a minimal clean installation (preferably a VM that you can share if necessary)?

The fix that landed in KDE Frameworks 5.65 (Comment #91) is for the situation when the disc is ejected from the device (CDEmu virtual device is empty) but the disc-related actions remain in Plasma "Device Notifier" menu. I tested with Plasma on today's installations of Fedora Rawhide and Arch Linux (both use 5.65), and this now seems to work as expected.

However, the issue in your video appears to be a different one: you are trying to eject the disc from CDEmu device, but for some reason that does not work, and you are left with a loaded device. That is why the CDEmu shows that device is (still) loaded, and why you can re-mount the device without having to reload the disc.

The problem is, I cannot reproduce this on Fedora Rawhide or on Arch Linux - in both cases, ejecting also seems to work as expected.

One thing that strikes me as odd is that in your video, the actions in the Device Notifier menu are "Click to access this device from other applications", followed by "Click to safely remove this device". And in Dolphin, you have "Safely remove".

On my installation, the actions are "Click to access this device from other applications", followed by "Click to eject this disc". Similarly, Dolphin has "Mount/Release" and "Eject" actions in my case.
Comment 97 Patrick Silva 2019-12-27 22:04:02 UTC
I can confirm the behavior shown in the video from comment 94 on my Arch Linux.
However everything works as expected on Neon unstable edition based on Ubuntu 18.04.
Comment 98 Nick Stefanov 2019-12-27 23:18:20 UTC
I'm on Arch too and this is the problem I described in my very first post in this thread - the disk is doesn't completely ejected and I have to eject it again with CDEmu. It's still there and it's shown on Dolphin side panel and on the Devices widget and I can't mount another disk until I egect the previous disk via CDEmu. I have a clean installation backup and the problem is there too. It used to work properly a long time ago but in last two years it's completely broken. And we are going to LTS - with scrambled icons on almost every restart and ISO ejecting problems. There isn't a single DE with such ridiculous problems. I'm a hardcore KDE fan but this really pisses me off...
Comment 99 postix 2020-01-04 11:24:32 UTC
I just tried it myself with the small slex-ipxe.iso [1] and cdemu 3.2.3 on

Operating System: Manjaro Linux 
KDE Plasma Version: 5.17.4
KDE Frameworks Version: 5.66.0
Qt Version: 5.14.0
Kernel Version: 5.4.7-1-MANJARO

on the testing repository branch and I can not reproduce your issue Nick. 
I wonder if this an Arch Linux issue as Patrick says it worked on KDE Neon Unstable -- though Manjaro uses the Arch repository.

[1] http://ftp.sh.cvut.cz/slax/Slax-9.x/slax-ipxe.iso (0.88 MB)
Comment 100 Nick Stefanov 2020-01-04 11:31:16 UTC
It's still here on my end :(
Comment 101 postix 2020-01-04 11:33:37 UTC
I have to correct my comment above:

I wanted to do demonstrate it to you with a recording done with a second and clean user account but then I could indeed reproduce the bug. 

Sometimes it also happens that Dolphin just crashes when I try to unmount the iso. After restarting Dolphin, now I got the mount symbol twice in the places panel.
Comment 102 postix 2020-01-04 11:38:16 UTC
I started Dolphin via the Konsole and get the following output if I try to unmount the ISO, though nothing happens:

```
QObject::disconnect: Unexpected null parameter
QObject::disconnect: Unexpected null parameter
QObject::disconnect: Unexpected null parameter
QObject::disconnect: Unexpected null parameter
```
Comment 103 Nick Stefanov 2020-01-04 11:53:06 UTC
I tried your ISO with a clean profile and the problem is still there. It's obvious the problem is in solid code. It's not our installations fault.
Comment 104 postix 2020-01-04 12:04:54 UTC
I did some more testing: 

1) I rebooted due to an update

2) Downloaded and compiled latest master of Dolphin (for gdb and debug build) and tested it there:
-> Worked fine for both the self compiled Dolphin and packaged Dolphin

3) Umount the ISO.

4) Switched to another user and tested it again: 
The bug occurs. 

5) Logged out and logged back in with the former user account:
Bug now occurs now here too.

The QObject::disconnect: Unexpected null parameter seem to be unrelated to this bug, though.
Comment 105 Nick Stefanov 2020-01-04 12:33:34 UTC
Thanks for investigating it. It's sad the devs don't care though...
Comment 106 Rok Mandeljc 2020-01-04 20:49:15 UTC
@Postix, thank you for thorough description of the test procedure. I am now able to reproduce the issue on Fedora Rawhide using two separate user accounts, one after the other:
1. log in as user A
2. ensure that CDEmu daemon is autostarted and virtual device is created (e.g., by querying device status)
3. log out
4. log in as user B
5. auto-start CDEmu daemon by loading virtual device with ISO image
-> instead of "Optical disc", Device Notifier shows "Storage Volume" and ejecting does not work

What is happening is that when user A logs out from Plasma, their CDEmu daemon instance (which was auto-started via D-Bus autostart mechanism) is not shut down (contrary to, for example, what happens when logging out of a GNOME session). So the above test steps result in two instances of CDEmu daemon running, one for each user, and each owning one virtual device. This is not an issue per-se (it was designed to work this way), but I think what is causing the problems here is that both virtual devices end up with the same serial number (which is based on number of devices, but only within a daemon instance).

For a quick test I patched CDEmu to use random serial numbers, and the issue went away. I will come up with a proper fix in the coming days (I would like to preserve stability of serial numbers and resulting /dev/disk/by-id symlinks, at least for single-user environments, so the serials should probably be based on global device counter, obtained from the vhba kernel module...) and push a new CDEmu release.

@Nick and @Patrick, do you use a multi-user setup? Or rather, when you observe the issue, do you have multiple CDEmu daemon instances running - intentionally or unintentionally?
Comment 107 Nick Stefanov 2020-01-04 21:01:27 UTC
@ Rok Mandeljc
Nope, I created the second profile just for testing the problem. I always use only one user profile but the problem is present on my end too :)
Comment 108 Rok Mandeljc 2020-01-04 21:20:11 UTC
Can you still check if you have two instances running - what is the output of "ps aux | grep cdemu-daemon"?

I checked the Arch linux package of cdemu-daemon, and it seems it also includes system service for running the daemon on system bus. Do you have this service (cdemu-daemon.service) enabled? If so, this is the source of second daemon instance, and what is triggering the issue in your case...
Comment 109 Nick Stefanov 2020-01-04 23:36:33 UTC
Thank you very much for your help :)

The output is:

https://pastebin.com/cMi4p7sE

Yes, cdemu-daemon.service was enabled. I disabled but now I can't mount CD/DVD images via double click or application chooser. Even the service menu has disappeared. It's now possible only when I start CDEmu manually, open it's GUI and mount the image via browsing. It's very inconvenient. And yes, if mount an image that way, the bug is not present and I can unmount it via the Devices widged or from the Dolphin's side panel.
Comment 110 Patrick Silva 2020-01-05 00:01:29 UTC
@Rok Mandeljc
I have two user accounts on my system and cdemu-daemon.service is enabled here.

Output of ps aux | grep cdemu-daemon:
root         487  0.0  0.1 328440 10152 ?        Ssl  20:54   0:00 cdemu-daemon --ctl-device=/dev/vhba_ctl --bus=system --num-devices=1 --audio-driver=null --logfile=/var/log/cdemu-daemon.log
stalker     3041  0.0  0.0   6324  2332 pts/1    S+   20:59   0:00 grep cdemu-daemon
Comment 111 Rok Mandeljc 2020-01-05 10:02:28 UTC
(In reply to Nick Stefanov from comment #109)
> Thank you very much for your help :)
> 
> The output is:
> 
> https://pastebin.com/cMi4p7sE
> 
> Yes, cdemu-daemon.service was enabled. I disabled but now I can't mount
> CD/DVD images via double click or application chooser. Even the service menu
> has disappeared. It's now possible only when I start CDEmu manually, open
> it's GUI and mount the image via browsing. It's very inconvenient. And yes,
> if mount an image that way, the bug is not present and I can unmount it via
> the Devices widged or from the Dolphin's side panel.

This sounds like misconfiguration on your side - the system-bus daemon instance should not be required for regular desktop use (it is intended only for headless systems that do not have session bus available due to lack of DE session).

The KDE CDEmu manager (kde_cdemu), which is what you are probably referring to as "the GUI" has hard-coded use of session-bus instance, while the official clients (cdemu-client, gcdemu) allow switching between system and session bus, but they default to session bus. The "Open with... CDEmu client" context menu action for ISO image uses cdemu-client; so if this stopped working, you might have manually configured the cdemu-client to use system bus at some point. Do you have one of the following config files on your system: /etc/cdemu-client.conf or ~/.cdemu-client? Can you check if running "cdemu status" from command-line (as regular user) works with cdemu-daemon.service disabled?

At any rate, KDE/solid does not seem to be at fault here (aside from not handling colliding device serial numbers), so this bug should be closed.

The device serials collision will be fixed in CDEmu, but you should also configure your systems to use only session-bus instance of CDEmu daemon (and perhaps the Arch packages should be adjusted to not provide the support for system-bus instance by default).
Comment 112 Nick Stefanov 2020-01-05 10:53:47 UTC
I have cdemu-client installed but when I stop cdemu-daemon.service and the "Open with... CDEmu client" context menu action disappears. I checked for /etc/cdemu-client.conf or ~/.cdemu-client but there aren't such files. 

Here's the output of "cdemu status" with cdemu-daemon.service disabled:
[mozo@mozo ~]$ cdemu status
Devices' status:
DEV   LOADED     FILENAME
0     False     

"you might have manually configured the cdemu-client to use system bus at some point."

I'm shure I didn't do that but how can I fix this?
Comment 113 Rok Mandeljc 2020-01-05 11:50:00 UTC
(In reply to Nick Stefanov from comment #112)
> I have cdemu-client installed but when I stop cdemu-daemon.service and the
> "Open with... CDEmu client" context menu action disappears. I checked for
> /etc/cdemu-client.conf or ~/.cdemu-client but there aren't such files. 
> 
> Here's the output of "cdemu status" with cdemu-daemon.service disabled:
> [mozo@mozo ~]$ cdemu status
> Devices' status:
> DEV   LOADED     FILENAME
> 0     False     
> 
> "you might have manually configured the cdemu-client to use system bus at
> some point."
> 
> I'm shure I didn't do that but how can I fix this?

Hmm, I guess something else is going on then. The "Open with..." action shows up as expected with cdemu-daemon.service disabled on my test Arch setup. As it should, since it is controlled only by /usr/share/applications/cdemu-client.desktop file and is (or at least it should be) independent of the service.

It does disappear from the "Open with..." if I make it a default application for the file type (by right clicking on file, selecting Properties, File Type Options, and then adjusting the order there). But in that case, the default action is on top of the context menu (above "Open With..."), and using either that or double-clicking on the image works.

When you said that double-clicking does not work, did you mean that "Open with CDEmu client" default action is gone, or it does not load the image?
Comment 114 Nick Stefanov 2020-01-05 14:25:56 UTC
Hmm, my fault, I'm sorry. Now I realized that It desappears for the Linux Mint 19.3 ISO, but it's there for other images. There isn't a way to add it for Linux Mint ISO though, which is a different MIME problem I suppose.

Now with cdemu-daemon.service stopped everything is working fine except some images that are not correctly recognized like Mint's ISO.

Thank you very much :)
Comment 115 Nick Stefanov 2020-01-05 14:28:01 UTC
Hmm, yes, the Linux Mint ISO is recognized as "Apple Disk image" and  therefore the problem.
Comment 116 Rok Mandeljc 2020-01-05 14:36:35 UTC
(In reply to Nick Stefanov from comment #115)
> Hmm, yes, the Linux Mint ISO is recognized as "Apple Disk image" and 
> therefore the problem.

The image in question does indeed seem to contain Apple descriptors as well (it is probably a ISO/HFS hybrid).

For now, you could try adding application/x-apple-diskimage to MimeType list in /usr/share/applications/cdemu-client.desktop file.
Comment 117 Nick Stefanov 2020-01-05 14:46:51 UTC
Thank you very much this workaround is working great! Thank you!
Comment 118 Patrick Silva 2020-01-09 11:36:01 UTC
cdemu 3.2.4 solved this issue on my Arch Linux. \o/
Thank you all.
Comment 119 Stefan Brüns 2020-11-03 06:11:02 UTC
Confirmed fixed.